Use sizeWithAttributes:
instead, which now takes an NSDictionary
. Pass in the pair with key UITextAttributeFont
and your font object like this:
CGRect rawRect = {};
rawRect.size = [string sizeWithAttributes: @{
NSFontAttributeName: [UIFont systemFontOfSize:17.0f],
}];
// Values are fractional -- you should take the ceil to get equivalent values
CGSize adjustedSize = CGRectIntegral(rawRect).size;
Related Contents:
- Cannot hide status bar in iOS7
- How to stop unwanted UIButton animation on title change?
- invalid context 0x0 under iOS 7.0 and system degradation
- Autoresizing issue of UICollectionViewCell contentView’s frame in Storyboard prototype cell (Xcode 6, iOS 8 SDK) happens when running on iOS 7 only
- iOS 7 sizeWithAttributes: replacement for sizeWithFont:constrainedToSize
- What happened to “HelveticaNeue-Italic” on iOS 7.0.3
- How to deprecate a method in Objective-C
- sizeWithFont method is deprecated. boundingRectWithSize returns an unexpected value
- Can’t endBackgroundTask: no background task exists with identifier, or it may have already been ended
- The app references non-public selectors in Payload/.app/: decoder
- How to change background color of UISearchBar in iOS7
- Unable to add UITextField to UIAlertView on iOS7…works in iOS 6
- UIBarButtonItem with UIImage Always Tinted iOS 7
- UITabBar not showing selected item images in ios 7
- iOS 7 – Keyboard animation
- Detecting user settings for Background App Refresh in iOS 7
- How do I call Objective-C code from Swift?
- @synthesize vs @dynamic, what are the differences?
- How do I iterate over an NSArray?
- @import vs #import – iOS 7
- CocoaPods Errors on Project Build
- #import using angle brackets < > and quote marks ” “
- What makes a keychain item unique (in iOS)?
- Xcode keeps asking for password to use the System Keychain
- How to make a class conform to a protocol in Swift?
- How to detect unused methods and #import in Objective-C
- Xcode linker error: file too small for architecture x86_64
- Is there any way to enforce typing on NSArray, NSMutableArray, etc.?
- Add button to navigationbar programmatically
- What’s the difference between ‘weak’ and ‘assign’ in delegate property declaration
- Sort NSArray of date strings or objects
- how to hide status bar when splash screen appears in iphone?
- How to view contents of NSDictionary variable in Xcode debugger?
- Declaring and checking/comparing (bitmask-)enums in Objective-C
- Converting all text to lower case in Objective-C
- Where is a Mac Application’s NSUserDefaults Data Stored?
- Difference between Foundation Framework and Core Foundation Framework?
- Objective-C dictionary inserting a BOOL
- Objective C: convert a NSMutableString in NSString
- Current view controller from AppDelegate?
- How do I get red green blue (RGB) and alpha back from a UIColor object?
- How to implement an IMP function that returns a large struct type determined at run-time?
- What’s the difference between performSelectorOnMainThread: and dispatch_async() on main queue?
- How to write regular expressions in Objective C (NSRegularExpression)?
- Fullscreen UIView with Status bar and Navigation Bar overlay on the top
- NSSet to NSArray casting calling objectAtIndex?
- How can I return instancetype in Swift [duplicate]
- dispatch_get_global_queue vs dispatch_get_main_queue
- Check if user finished sliding on a continuous UISlider?
- Capture groups not working in NSRegularExpression