The app I am working on is a near replicate of Apple's default iPhone calculator app.
I am having a hard time in keeping the corner radius set for both the basic operator buttons in portrait and the basic operator buttons plus additional buttons in landscape mode.
Is specifying the corner radius (by dividing the UIButton.bounds.height / 2
) in viewWillLayoutSubviews()
the right place?
I need the buttons left and right side to stay round on all device rotations. I am not concerned with the top and bottom of the buttons being round.
Thank you all for your consideration in helping me figure out this issue. I am not looking for a direct answer, but if you all could maybe point me to some topics to look into that would be a huge help. I have also tried setting the corner radius in viewDidAppear().
Looking for a programmatic solution using UIButton.bounds.height.
I believe I am just trying to find the right method to implement the corner radius through
var cornerRadius_forButtons: Double = 0
if UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft{
cornerRadius_forButtons = Double(tag1_Button.bounds.height / 2.0)
}
else if UIDevice.current.orientation == UIDeviceOrientation.landscapeRight{
cornerRadius_forButtons = Double(tag1_Button.bounds.height / 2.0)
} else {
cornerRadius_forButtons = Double(tag1_Button.bounds.height / 2.0)
}
UIButton.layer.cornerRadius = CGFloat(cornerRadius_forButtons)