Tag Archives: Xcode

Swift Tips #1: Extra padding problem on UITextView?

Sometimes when you integrate a design, you need things to be square, everything aligned: buttons, title, images, textView… But wait, what’s that extra padding on the UITextView? You may have tried to print the contentOffset or contentInset without success. That’s not it. However, all your problems can be solved in one line, and here it is: // magic line for a UITextView named textView textView.textContainer.lineFragmentPadding = 0 I wouldn’t call it exactly straight forward, so this is a memo for me and tip for you :)

UIFont not responding or nil

My font does not respond and it says nil when I print it? What’s happening here? Actually, if your UIFont happens to be nil, it’s maybe because you’re not calling it properly! Haha, very funny, I know, but let’s have a look at happened to me recently. Here is what I did: I imported “MyFont-Regular.ttf” and “MyFont-bold.ttf” in Xcode. I set the constants with the font name. let fontRegular = “MyFont-Regular” let fontBold = “MyFont-Bold” And I set the font to that label in the view: label.font = UIFont(name: fontRegular, size: 12.0) and … nothing happened, well, the label was displayed … Continue reading UIFont not responding or nil