Created
July 20, 2016 08:11
-
-
Save quangtqag/d84d0e09ac5bda698bec40a9047f95eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myLabel.backgroundColor = UIColor.greenColor() | |
myLabel.text = "What Do I Want to Do?(Select One)" | |
myLabel.adjustsFontSizeToFitWidth = true | |
myLabel.minimumScaleFactor = 0.1 | |
let attributes = [NSFontAttributeName : myLabel.font] | |
let attributedString = NSMutableAttributedString(string:textString, attributes:attributes) | |
let context = NSStringDrawingContext() | |
context.minimumScaleFactor = myLabel.minimumScaleFactor | |
attributedString.boundingRectWithSize( | |
myLabel.bounds.size, | |
options: .UsesLineFragmentOrigin, | |
context: context) | |
print("actual context after drawing: \(context.actualScaleFactor)") | |
let actualFontSize = myLabel.font.pointSize * context.actualScaleFactor | |
print("actualFontSize = \(actualFontSize)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment