Reputation: 1601
I'm having issues with my app design,
I have a Textfield on my view, and I positioned it and sized it (by dragging the element) to how I want it:
but when I view it in the simulator, it looks like this:
As you can see, it is bigger and unsightly. It goes right to the edge. How do I make sure that it will look the same across all iOS Devices and in the Simulator?
Bi of a noob here so hoping for a detailed answer.
Thanks.
P.s I'm using swift if there is any code requirements.
Upvotes: 0
Views: 54
Reputation: 3956
In viewDidLoad
try setting width of your textfield manually depending on the width of your screen. Try this out
var newFrame = textField.frame
newFrame.size.width = self.view.frame.size.width - 50 //change 50 according to your needs
newFrame.origin.x = 25 //should be half of constant set above so that textfield is in centre
textField.frame = newFrame
Upvotes: 0
Reputation: 127
Use auto layout. Auto layout is a way to add constraints to your UI allowing for you to fix problems like yours and allows for your to have a similar UI across multiple screen sizes with relative ease. http://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2
Upvotes: 1