Dynamically changing font size of UILabel

I currently have a UILabel: factLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)]; factLabel.text = @”some text some text some text some text”; factLabel.backgroundColor = [UIColor clearColor]; factLabel.lineBreakMode = UILineBreakModeWordWrap; factLabel.numberOfLines = 10; [self.view addSubview:factLabel]; Throughout the life of my iOS application, factLabel gets a bunch of different values. Some with multiple sentences, others with … Read more

Figure out size of UILabel based on String in Swift

I am trying to calculate the height of a UILabel based on different String lengths. func calculateContentHeight() -> CGFloat{ var maxLabelSize: CGSize = CGSizeMake(frame.size.width – 48, CGFloat(9999)) var contentNSString = contentText as NSString var expectedLabelSize = contentNSString.boundingRectWithSize(maxLabelSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName: UIFont.systemFontOfSize(16.0)], context: nil) print(“\(expectedLabelSize)”) return expectedLabelSize.size.height } Above is the current function I use … Read more

Adding space/padding to a UILabel

I have a UILabel where I want to add space in the top and in the bottom. With the minimum height in constraints, I’ve modified it to: To do this I’ve used: override func drawTextInRect(rect: CGRect) { var insets: UIEdgeInsets = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0) super.drawTextInRect(UIEdgeInsetsInsetRect(rect, insets)) } But I’ve to … Read more

Create tap-able “links” in the NSAttributedString of a UILabel?

I have been searching this for hours but I’ve failed. I probably don’t even know what I should be looking for. Many applications have text and in this text are web hyperlinks in rounded rect. When I click them UIWebView opens. What puzzles me is that they often have custom links, for example if words … Read more