Reputation: 1895
I've been trying to create a button where basically for 4.7" screen devices and up a button an embedded image over the title is to be displayed. For smaller screens (4" and lower) the button should be just text without image. I've tried using Insets to position the image and title where it needs to go but problem with that is when you go from 4.7" inch to 5.5" or 4" the results are out of wack.
For example if i wanted this button:
on 4.7" and up devices and following on 4" and lower:
How do you guys do this? Note that I am not using Auto layout and size classes given the project isn't enabled to use auto layout.... Also my project is in Swift 2 Xcode 7
Upvotes: 0
Views: 56
Reputation: 1000
You can check the bounds of the view and create a different button depending on the screen size.
func createButton() -> UIButton {
let button = UIButton()
let minimumHeight:CGFloat = 667.0 //iPhone6
let currentView = self.view.frame.height
if currentView < minimumHeight {
//create small button
} else {
//create large button
}
return button
}
Upvotes: 1