代码:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self addUnderLine]; } #pragma -mark -functions //添加下划线 -(void)addUnderLine { //UILabel UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 200)]; label.backgroundColor=[UIColor redColor]; [self.view addSubview:label]; //显示下划线 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@" 价格:40" attributes:attribtDic]; label.attributedText = attribtStr; }
时间: 2024-10-09 14:34:03