UILineBreakMode Vs NSLineBreakMode

China☆狼群 提交于 2019-12-05 18:53:44

问题


I see some UIStringDrawing methods have been updated to use NSLineBreakMode instead of UILineBreakMode in iOS 6.0:

E.g.

- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode

How can I check for this to ensure my iOS 5 users and below continue to use UILineBreakMode?


回答1:


No checking is necessary. These are just enums and they map to the same values

You can see there is no real difference here:

UILineBreakMode vs NSLineBreakMode

  enum {
   NSLineBreakByWordWrapping = 0,
   NSLineBreakByCharWrapping,
   NSLineBreakByClipping,
   NSLineBreakByTruncatingHead,
   NSLineBreakByTruncatingTail,
   NSLineBreakByTruncatingMiddle
};
typedef NSUInteger NSLineBreakMode



typedef enum {
   UILineBreakModeWordWrap = 0,
   UILineBreakModeCharacterWrap,
   UILineBreakModeClip,
   UILineBreakModeHeadTruncation,
   UILineBreakModeTailTruncation,
   UILineBreakModeMiddleTruncation,
} UILineBreakMode;



回答2:


UILineBrakeMode is deprecated in ios6 http://developer.apple.com/library/ios/#documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html#//apple_ref/doc/c_ref/UILineBreakMode



来源:https://stackoverflow.com/questions/12714956/uilinebreakmode-vs-nslinebreakmode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!