[英]iOS NSAttributedString rounded background with color
我想創建類似此圖片所示的內容:
我設法用NSMutableAttributedString創建了Evertyhing,除了橙色的圓角矩形。 我可以使用BackgroundColor將背景設置為該顏色,但是我找不到使它變圓的方法。 任何樣本我該如何實現? 我找到了這個答案,但無法在Monotouch中使用: NSAttributedString背景顏色和圓角
我在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;
我是通過在單獨的UILabel
進行制作來實現的,如果您願意,可以使用以下代碼:
myLabel.layer.cornerRadius = 8;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.