facebookarchive / AsyncDisplayKit

Smooth asynchronous user interfaces for iOS apps.
http://asyncdisplaykit.org
Other
13.4k stars 2.2k forks source link

ASButtonNode highlighted titles shifts to the right #3352

Open Gazomba opened 5 years ago

Gazomba commented 5 years ago

I have a problem with ASButtonNode and attributedTitle for different control states and using fractional size. The title becomes shifted to the left.

I behaved correctly if I use a point size for the button.

I am running texture/asyncDisplayKit 2.8.1.

/* Set title */
testButton.setAttributedTitle(NSAttributedString(string: "NORMAL"), for: .normal)
testButton.setAttributedTitle(NSAttributedString(string: "HIGHLIGHTED"), for: .highlighted)

/* styling */
/** This works
 * testButton.style.width = ASDimensionMake("120pt") 
 **/
testButton.style.width = ASDimensionMake("30%")
testButton.style.height = ASDimensionMake(120)

The title should not get shifted to the right after tapping the button. Am I missing something?

Before highlighted: Screenshot 2019-06-04 at 08 56 35 After highlighted: Screenshot 2019-06-04 at 08 56 39

When changing ASButtonNode.mm line 206:

[self setNeedsLayout];

to:

[_titleNode setNeedsLayout];

It works as expected.

Related Stackoverflow post: https://stackoverflow.com/questions/56439080/asbuttonnode-attributedtitle-for-different-controlstates

appleguy commented 5 years ago

Could you request on the Texture project?

On Tue, Jun 4, 2019 at 6:38 AM maliCaspeco notifications@github.com wrote:

I have a problem with ASButtonNode and attributedTitle for different control states and using fractional size. The title becomes shifted to the left.

I behaved correctly if I use a point size for the button.

I am running texture/asyncDisplayKit 2.8.1.

/ Set title / testButton.setAttributedTitle(NSAttributedString(string: "NORMAL"), for: .normal) testButton.setAttributedTitle(NSAttributedString(string: "HIGHLIGHTED"), for: .highlighted)

/ styling / /** This works

  • testButton.style.width = ASDimensionMake("120pt") **/ testButton.style.width = ASDimensionMake("30%") testButton.style.height = ASDimensionMake(120)

The title should not get shifted to the right after tapping the button. Am I missing something?

Before highlighted: [image: Screenshot 2019-06-04 at 08 56 35] https://user-images.githubusercontent.com/24386953/58883217-403b4a80-86de-11e9-8587-488146f32029.png After highlighted: [image: Screenshot 2019-06-04 at 08 56 39] https://user-images.githubusercontent.com/24386953/58883218-403b4a80-86de-11e9-970a-99b0ba67a59f.png

When changing ASButtonNode.mm line 206:

[self setNeedsLayout];

to:

[_titleNode setNeedsLayout];

It works as expected.

Related Stackoverflow post: https://stackoverflow.com/questions/56439080/asbuttonnode-attributedtitle-for-different-controlstates

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/facebookarchive/AsyncDisplayKit/issues/3352?email_source=notifications&email_token=AAEKAA3PWVBSZ437PO5EW63PYZV4TA5CNFSM4HS4OKXKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GXRAMOA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEKAAZEONKMFCIIIEOZZW3PYZV4TANCNFSM4HS4OKXA .

Gazomba commented 5 years ago

Yeah sorry, noticed. I did for some days ago.

https://github.com/TextureGroup/Texture/issues/1534