stikethrough
有可能UILabel
吗?我似乎找不到选项...
问问题
9674 次
5 回答
9
于 2012-12-15T08:52:14.770 回答
4
您可以在标签上方创建另一个 UILabel 并使用短划线字符:
label.text = @"––––––––––––––––––";
警告:适用于 Helvetica(系统默认)。它可能不适用于其他字体。
于 2011-01-31T23:23:26.890 回答
3
iPhone 不支持属性字符串(这通常是您在 Cocoa 中执行此操作的方式),所以我不相信这是可能的。
您可以子类UILabel
化并绘制strikethrough
自己。我也看到有些人使用 aUIWebView
来做这种事情,但这对我来说似乎有点矫枉过正。
于 2009-06-28T07:03:48.657 回答
1
NSAttributedString *str=[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%.2f", productOne.priceBefore] attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle)}];
cell.priceBefore.attributedText = str;
于 2014-11-28T03:56:14.283 回答
1
UIView* slabel = [[UIView alloc] initWithFrame:CGRectMake(label.frame.origin.x, label.frame.origin.y+10, label.frame.size.width, 2)];
[self addSubview:slabel];
[slabel setBackgroundColor:label.textColor];
您可以在 UILabel 上添加一个视图并使用标签属性对其进行样式设置。
于 2012-12-04T11:08:53.130 回答