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 forNSUnderlinestyleAttributename
andNsstrikethroughStyleAttributename
.
以上是内存溢出为你收集整理的ios – UIButton在Objective c中划线全部内容,希望文章能够帮你解决ios – UIButton在Objective c中划线所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)