How to fix 'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: warning

Utku Dalmaz

My code is

CGSize textSize =  [text sizeWithFont:font constrainedToSize:CGSizeMake(self.bounds.size.width - 106, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];

Anyone knows how can i fix this warning?

Sheereen S

Swift

 // adjust the label height (top align text)
// old
var labelSize: CGSize = model.name.sizeWithFont(self.nameLabel.font,  constrainedToSize: maxNameLabelSize, lineBreakMode: self.nameLabel.lineBreakMode)
// new
var labelSize: CGSize = model.name.boundingRectWithSize(maxNameLabelSize, options: .UsesLineFragmentOrigin, attributes: [NSFontAttributeName: self.nameLabel.font], context: nil).size

Objective c

 // adjust the label height (top align text)
 // old
CGSize labelSize = [model.name sizeWithFont:self.nameLabel.font
                      constrainedToSize:_maxNameLabelSize
                          lineBreakMode:self.nameLabel.lineBreakMode];
 // new
CGSize labelSize = [model.name boundingRectWithSize:_maxNameLabelSize
                                        options:NSStringDrawingUsesLineFragmentOrigin
                                     attributes:@{NSFontAttributeName: self.nameLabel.font}
                                        context:nil].size;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

'sizeWithFont:constrainedToSize:lineBreakMode:'is deprecated:

From Java

Replacement for deprecated -sizeWithFont:constrainedToSize:lineBreakMode: in iOS 7?

From Dev

sizeWithFont:constrainedToSize:lineBreakMode: deprecated in iOS7

From Dev

sizeWithFont: ConstrainedToSize: lineBreakMode: method is deprecated in iOS 7

From Dev

'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

From Dev

Transition from sizewithFont:constrainedToSize:lineBreakMode: for iOS 7 not behaving as expected

From Dev

Deprecate sizeWithFont: UIFont constrainedToSize:CGSize lineBreakMode:NSLineBreakMode in MBProgressHud

From Dev

CGSize sizeSpace = [@" " sizeWithFont:self.fontHashtag constrainedToSize:rect.size lineBreakMode:self.lineBreakMode];

From Dev

How to fix warning init() is deprecated

From Dev

Replacement for sizeWithFont:ForWidth:lineBreakMode:

From Dev

How can I fix the "UIPopoverController is deprecated" warning?

From Dev

how to fix gtkmm warning : deprecated-declarations

From Java

iOS 7 sizeWithAttributes: replacement for sizeWithFont:constrainedToSize

From Dev

How to fix 'warning #1173-D: attribute "deprecated" ignored?'

From Dev

IOS 7 sizeWithFont Deprecated

From Dev

IOS 7 sizeWithFont Deprecated

From Dev

How to fix deprecated substring(with: )

From Java

Replacement for deprecated sizeWithFont: in iOS 7?

From Dev

how to supress warning "gets() is deprecated"?

From Dev

How to fix warning in Rails

From Java

Fix "Interpolation-only expressions are deprecated" warning in Terraform

From Dev

Fix warning "C-style for Statement is deprecated" in Swift 3

From Dev

Fix for getting "deprecated and will be removed in Swift 4" warning for tableView functions

From Dev

Lost with the replacement for deprecated sizeWithFont: in iOS 7

From Dev

How to hide "Deprecated: mysql_connect()" warning?

From Dev

How to hide "Deprecated: mysql_connect()" warning?

From Dev

How to fix warning 'no explicit ownership'

From Dev

How to fix leiningen :aot warning

From Dev

How to fix this unchecked assignment warning?

Related Related

  1. 1

    'sizeWithFont:constrainedToSize:lineBreakMode:'is deprecated:

  2. 2

    Replacement for deprecated -sizeWithFont:constrainedToSize:lineBreakMode: in iOS 7?

  3. 3

    sizeWithFont:constrainedToSize:lineBreakMode: deprecated in iOS7

  4. 4

    sizeWithFont: ConstrainedToSize: lineBreakMode: method is deprecated in iOS 7

  5. 5

    'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

  6. 6

    Transition from sizewithFont:constrainedToSize:lineBreakMode: for iOS 7 not behaving as expected

  7. 7

    Deprecate sizeWithFont: UIFont constrainedToSize:CGSize lineBreakMode:NSLineBreakMode in MBProgressHud

  8. 8

    CGSize sizeSpace = [@" " sizeWithFont:self.fontHashtag constrainedToSize:rect.size lineBreakMode:self.lineBreakMode];

  9. 9

    How to fix warning init() is deprecated

  10. 10

    Replacement for sizeWithFont:ForWidth:lineBreakMode:

  11. 11

    How can I fix the "UIPopoverController is deprecated" warning?

  12. 12

    how to fix gtkmm warning : deprecated-declarations

  13. 13

    iOS 7 sizeWithAttributes: replacement for sizeWithFont:constrainedToSize

  14. 14

    How to fix 'warning #1173-D: attribute "deprecated" ignored?'

  15. 15

    IOS 7 sizeWithFont Deprecated

  16. 16

    IOS 7 sizeWithFont Deprecated

  17. 17

    How to fix deprecated substring(with: )

  18. 18

    Replacement for deprecated sizeWithFont: in iOS 7?

  19. 19

    how to supress warning "gets() is deprecated"?

  20. 20

    How to fix warning in Rails

  21. 21

    Fix "Interpolation-only expressions are deprecated" warning in Terraform

  22. 22

    Fix warning "C-style for Statement is deprecated" in Swift 3

  23. 23

    Fix for getting "deprecated and will be removed in Swift 4" warning for tableView functions

  24. 24

    Lost with the replacement for deprecated sizeWithFont: in iOS 7

  25. 25

    How to hide "Deprecated: mysql_connect()" warning?

  26. 26

    How to hide "Deprecated: mysql_connect()" warning?

  27. 27

    How to fix warning 'no explicit ownership'

  28. 28

    How to fix leiningen :aot warning

  29. 29

    How to fix this unchecked assignment warning?

HotTag

Archive