3

How can I specify the text offset (or if you prefer padding size) in my "UILabel" field in UIBilder ?

The text starts exactly on the border, and I would like to specify padding (such as in css) because I'm also assigning a background color to the label.

thanks

aneuryzm
  • 63,052
  • 100
  • 273
  • 488

1 Answers1

6

I think you'll have to embed your UILabel inside a wrapper UIView, offset the UILabel by setting it's frame x,y. Then specify the background color in the wrapper view.

Rayfleck
  • 12,116
  • 8
  • 48
  • 74
  • Please help me in this. I have a custom row in a section of a table. this custom row is a xib file which has a label, text, images. I works on Iphone with width, height but distorts on Ipad. How do we handle these things in IOS? I have only 1 iphone to test. Will that tableviewcell xib distort on other iphones too depending on 2x, 3x etc.? How to make sure that eveything works fine in all phones? (IOS )Please clear this thing. – hellodear Feb 14 '17 at 06:45
  • @hellodear - you need to use Size Classes to constrain all the views in relation to each other and their containing views. Here's a tut from Ray: https://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started. You can examine how they will look in IB (View As: size and orientation), and you can run them on almost any device in the simulator. – Rayfleck Feb 15 '17 at 16:04