UILabel显示富文本

2019-04-14 15:26发布



UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 90, 150, 50)]; NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; attributes[NSStrokeColorAttributeName] = [UIColor blueColor]; attributes[NSStrokeWidthAttributeName] = @6; NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowColor = [UIColor redColor]; shadow.shadowBlurRadius = 5; shadow.shadowOffset = CGSizeMake(10, 10); attributes[NSShadowAttributeName] = shadow; label.attributedText = [[NSAttributedString alloc] initWithString:@"我的地盘" attributes:attributes]; [self.view addSubview:label];