Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10099] Button Bug #3514

Closed
swift-ci opened this issue Mar 13, 2019 · 1 comment
Closed

[SR-10099] Button Bug #3514

swift-ci opened this issue Mar 13, 2019 · 1 comment

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-10099
Radar None
Original Reporter SmushyTaco (JIRA User)
Type Bug
Status Resolved
Resolution Invalid

Attachment: Download

Environment

Computer Specs:

MacBook Pro (13-inch, Late 2011)
Processor 2.4 GHz Intel Core i5

Memory 8 GB 1333 MHz DDR3

Graphics Intel HD Graphics 3000 512 MB

iPhone Xr Specs:
Color: Black
Storage: 128GB
iOS Version: 12.1.2
Any Modifications (Jailbreaking, etc): No

Additional Detail from JIRA
Votes 0
Component/s Compiler, Foundation, Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 1dd25e00ec2a8e4971f839ddb7c8e484

Issue Description:

So I'm making a password generator using pure code and Swift and I ran into a weird issue. So I want the buttons to be rounded but I can't just hardcode a value to round it like:

mainButton.layer.cornerRadius = 10

Because with UIStackViews the size of the button is different on all devices and device orientations so as a solution I tried using:

**override** **func** viewDidLayoutSubviews() {

    mainButton.layer.cornerRadius = mainButton.frame.size.height/2

}

So whenever the device orientation changes it updates the button and tries rounding it but whenever the orientation changes it gets messed up and then properly rounds after being clicked. So after that I was now even more confused so I tried:

override func viewDidLayoutSubviews() {

    mainButton.layer.cornerRadius = mainButton.frame.size.height/2

    mainButton.sendActions(for: .touchUpInside)

}

To emulate a button click so the button wouldn't distort and would seem normal to the user but that also didn't work and the exact same output happened so then I tried:

**override** **func** viewDidLayoutSubviews() {

    mainButton.layer.cornerRadius = mainButton.frame.size.height/2

    **self**.view.layoutIfNeeded()

}

and the same outcome came out of it so then I also tried:

**override** **func** viewDidLayoutSubviews() {

    mainButton.layer.cornerRadius = mainButton.frame.size.height/2

    **self**.mainButton.layoutIfNeeded()

}

and the same result also came out of that.

@belkadan
Copy link

Hi, Nikan. This bug tracker is for issues with the Swift language and libraries, not with UIKit and iOS. (I know the lines are sometimes blurred here, but basically we're not the ones who can fix UIKit!)

I'm also not sure if this is a bug or a question, so you may have better luck at https://forums.developer.apple.com than https://bugreport.apple.com.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants