2013-12-09 83 views
2

背景,我想这个图像上看到创建类似的东西:的iOS NSAttributedString圆润与色彩

enter image description here

我设法创建NSMutableAttributedString evertyhing,除了橙色的圆角矩形。我可以使用BackgroundColor将背景设置为该颜色,但我无法找到使其圆整的方法。任何样本我怎么能做到这一点?我发现这个答案,但我不能让它在MonoTouch的工作:NSAttributedString background color and rounded corners

我在Xamarin.iOS代码:

var stringBuilder = new NSMutableAttributedString(); 
stringBuilder.Append(new NSAttributedString("26")); 
stringBuilder.SetAttributes(new UIStringAttributes(){BackgroundColor = UIColor.Orange}, new NSRange(stringBuilder.Length - appendString.Length, appendString.Length)); 
label.AttributedText = stringBuilder; 

回答

-2

我通过使它在一个单独的UILabel实现这一点,你可以用这个代码如果多数民众赞成你是否想要去的方式:

myLabel.layer.cornerRadius = 8; 
+0

这对我不起作用,因为我只使用一个标签来显示所有的值。 – Roosevelt