[英]how to draw a text on a circle in SWIFT
我不知道如何開始,所以我也沒有任何代碼。 到目前為止,我的研究指出,沒有標准功能,這必須由我們自己編寫?
任何提示或確認?
使用 Ashish 建議的 CoreTextArcView 進行更新。
謝謝你的幫助。 建議的示例項目對我有用。 我可以看到上面有文字的藍色圓圈。 但是將它集成到我的項目中時,我遇到了問題。 我做了以下
我將文件"CoreTextArcView.h"
和"CoreTextArcView.m"
到我的項目中。 我可以在左側的資源管理器中看到它們。
在我的 BridgingHeader.h 中,我添加了 import : #import "CoreTextArcView.h"
我添加了 Codesample :
var arctext : CoreTextArcView = CoreTextArcView(frame: CGRectMake(50, 50, 200, 200), font: UIFont.systemFontOfSize(15), text: "Hello this is radious arc with text", radius: 85, arcSize: 130.0, color : UIColor.redColor()) arctext.backgroundColor = UIColor.clearColor() self.view.addSubview(arctext)
-> 我在CoreTextArcView.m
得到編譯錯誤:
/Users/user/Desktop/Prototypes/CoreTextArcView.m
/Users/user/Desktop/Prototypes/CoreTextArcView.m:99:14: 'release' is unavailable: not available in automatic reference counting mode
/Users/user/Desktop/Prototypes/CoreTextArcView.m:99:14: ARC forbids explicit message send of 'release'
/Users/user/Desktop/Prototypes/CoreTextArcView.m:100:21: 'retain' is unavailable: not available in automatic reference counting mode
/Users/user/Desktop/Prototypes/CoreTextArcView.m:100:21: ARC forbids explicit message send of 'retain'
/Users/user/Desktop/Prototypes/CoreTextArcView.m:144:33: Cast of Objective-C pointer type 'NSAttributedString *' to C pointer type 'CFAttributedStringRef' (aka 'const struct __CFAttributedString *') requires a bridged cast
/Users/user/Desktop/Prototypes/CoreTextArcView.m:190:63: Cast of C pointer type 'CTFontRef' (aka 'const struct __CTFont *') to Objective-C pointer type 'UIFont *' requires a bridged cast
/Users/user/Desktop/Prototypes/CoreTextArcView.m:298:37: Cast of C pointer type 'CTFontRef' (aka 'const struct __CTFont *') to Objective-C pointer type 'id' requires a bridged cast
/Users/user/Desktop/Prototypes/CoreTextArcView.m:307:24: 'autorelease' is unavailable: not available in automatic reference counting mode
/Users/user/Desktop/Prototypes/CoreTextArcView.m:307:24: ARC forbids explicit message send of 'autorelease'
有什么幫助嗎?
通過使用這個庫: https : //github.com/javenisme/CurvaView
var arctext : CoreTextArcView = CoreTextArcView(frame: CGRectMake(50, 50, 200, 200), font: UIFont.systemFontOfSize(15), text: "Hello this is radious arc with text", radius: 85, arcSize: 130.0, color: UIColor.redColor())
arctext.backgroundColor = UIColor.clearColor()
self.view.addSubview(arctext)
刪除一個文件的弧,如下所示(從項目目標的構建階段將-fno-objc-arc
設置為該庫的 .m 文件):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.