ios – UIButton在Objective c中划线

ios – UIButton在Objective c中划线,第1张

概述正常的下划线工作但点缀的下划线似乎不起作用? UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(100, 10, 300, 300);NSMutableAttributedString *titleString = [[NSMutableAttributedString al 正常的下划线工作但点缀的下划线似乎不起作用?

UIbutton *btn = [UIbutton buttonWithType:UIbuttonTypeCustom]; btn.frame = CGRectMake(100,10,300,300);NSMutableAttributedString *TitleString = [[NSMutableAttributedString alloc] initWithString:@"Durga Vundavalli"];// making text property to underline text-[TitleString addAttribute:NSUnderlinestyleAttributename value:[NSNumber numberWithInteger:NSUnderlinestyleSingle] range:NSMakeRange(0,[TitleString length])];// using text on button[btn setAttributedTitle: TitleString forState:UIControlStatenormal];[self.vIEw addSubvIEw:btn];

以下是文档中的枚举:

typedef NS_ENUM(NSInteger,NSUnderlinestyle) {    NSUnderlinestyleNone                                = 0x00,NSUnderlinestyleSingle                              = 0x01,NSUnderlinestyleThick NS_ENUM_AVAILABLE_IOS(7_0)    = 0x02,NSUnderlinestyleDouble NS_ENUM_AVAILABLE_IOS(7_0)   = 0x09,NSUnderlinePatternSolID NS_ENUM_AVAILABLE_IOS(7_0)      = 0x0000,NSUnderlinePatternDot NS_ENUM_AVAILABLE_IOS(7_0)        = 0x0100,NSUnderlinePatternDash NS_ENUM_AVAILABLE_IOS(7_0)       = 0x0200,NSUnderlinePatternDashDot NS_ENUM_AVAILABLE_IOS(7_0)    = 0x0300,NSUnderlinePatternDashDotDot NS_ENUM_AVAILABLE_IOS(7_0) = 0x0400,NSUnderlineByWord NS_ENUM_AVAILABLE_IOS(7_0) = 0x8000}
解决方法 你不能只放NSUnderlinePatternDot.如果你想要2行点怎么办?你必须使用模式和样式.

[TitleString addAttribute:NSUnderlinestyleAttributename value:[NSNumber numberWithInteger:(NSUnderlinePatternDot|NSUnderlinestyleSingle)] range:NSMakeRange(0,[TitleString length])];

您必须使用掩码,如文档所述:

discussion
The style,pattern,and optionally by-word mask are OR’d
together to produce the value for NSUnderlinestyleAttributename and
NsstrikethroughStyleAttributename.

总结

以上是内存溢出为你收集整理的ios – UIButton在Objective c中划线全部内容,希望文章能够帮你解决ios – UIButton在Objective c中划线所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1006178.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存