Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####
- ## Adjusting font size according to the height of an UILabel.
- ## For more details, refer to this Stack Overflow thread:
- ## http://bit.ly/setFontSizeToFillUILabelHeight
- ####
- minFontSize: 18.0
- maxFontSize: 67.0
- fontSizeAverage: 0.0
- textAndLabelHeightDiff: 0.0
- ### Iteration number: 1 ###
- minFontSize: 18.0
- maxFontSize: 67.0
- fontSizeAverage: 42.5
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 42.5
- textAndLabelHeightDiff: -2.0
- maxFontSize: 41.5
- ### Iteration number: 2 ###
- minFontSize: 18.0
- maxFontSize: 41.5
- fontSizeAverage: 29.75
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 29.75
- textAndLabelHeightDiff: 10.75
- minFontSize: 30.75
- ### Iteration number: 3 ###
- minFontSize: 30.75
- maxFontSize: 41.5
- fontSizeAverage: 36.125
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 36.125
- textAndLabelHeightDiff: 4.375
- minFontSize: 37.125
- ### Iteration number: 4 ###
- minFontSize: 37.125
- maxFontSize: 41.5
- fontSizeAverage: 39.3125
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 39.3125
- textAndLabelHeightDiff: 1.1875
- minFontSize: 40.3125
- ### Iteration number: 5 ###
- minFontSize: 40.3125
- maxFontSize: 41.5
- fontSizeAverage: 40.9062
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 40.9062
- textAndLabelHeightDiff: -0.40625
- maxFontSize: 39.9062
- Returned font with size: <UICTFont: 0x7a663920> font-family: "ProximaNovaCond-Black"; font-weight: bold; font-style: normal; font-size: 40.91pt
- minFontSize: 18.0
- maxFontSize: 67.0
- fontSizeAverage: 0.0
- textAndLabelHeightDiff: 0.0
- ### Iteration number: 1 ###
- minFontSize: 18.0
- maxFontSize: 67.0
- fontSizeAverage: 42.5
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 42.5
- textAndLabelHeightDiff: -2.0
- maxFontSize: 41.5
- ### Iteration number: 2 ###
- minFontSize: 18.0
- maxFontSize: 41.5
- fontSizeAverage: 29.75
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 29.75
- textAndLabelHeightDiff: 10.75
- minFontSize: 30.75
- ### Iteration number: 3 ###
- minFontSize: 30.75
- maxFontSize: 41.5
- fontSizeAverage: 36.125
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 36.125
- textAndLabelHeightDiff: 4.375
- minFontSize: 37.125
- ### Iteration number: 4 ###
- minFontSize: 37.125
- maxFontSize: 41.5
- fontSizeAverage: 39.3125
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 39.3125
- textAndLabelHeightDiff: 1.1875
- minFontSize: 40.3125
- ### Iteration number: 5 ###
- minFontSize: 40.3125
- maxFontSize: 41.5
- fontSizeAverage: 40.9062
- labelText: $0.99
- labelHeight: 40.5
- testStringHeight: 40.9062
- textAndLabelHeightDiff: -0.40625
- maxFontSize: 39.9062
- Returned font with size: <UICTFont: 0x7a663920> font-family: "ProximaNovaCond-Black"; font-weight: bold; font-style: normal; font-size: 40.91pt
Add Comment
Please, Sign In to add comment