UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)];
[self.view addSubview:lable];
lable.backgroundColor = [UIColor redColor];
lable.textAlignment = NSTextAlignmentCenter;
NSString *oldPrice = @"¥ 999999";
NSUInteger length = [oldPrice length];
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];
[attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];
[attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(0, length)];
[lable setAttributedText:attri]; UILabel设置删除线(电商商品价格)
最新推荐文章于 2023-08-11 14:58:37 发布
本文深入探讨了使用Objective-C语言构建iOS应用程序的过程,从基础语法到高级特性,包括如何利用Swift与Objective-C混合编程,实现更高效、更安全的应用开发。通过实例演示了如何创建一个简单的iOS应用,涵盖界面设计、数据处理、网络请求等关键步骤,旨在帮助开发者快速上手并提升编程技能。
189

被折叠的 条评论
为什么被折叠?



