2015-04-23 55 views
-4

有人可以建議我用iOS中的顏色填充自定義數量的圓圈嗎?如何在iOS中用自定義數量填充顏色來繪製圓圈?

+0

你是什麼意思。請分享預期輸出的截圖。 –

+0

詢問前請先搜索。 [Here's](http://stackoverflow.com/questions/3729690/draw-part-of-a-circle)從搜索中擊中。 – trojanfoe

+0

你可以看看這個https://github.com/Marxon13/M13ProgressSuite –

回答

0
  1. 在main.storyboard
  2. 創建一個按鈕,創建一個新的類和新類中指定這個新類新的按鈕
  3. 添加以下代碼

進口的UIKit

@IBDesignable class YourNewClass: UIButton { 

    @IBInspectable var fillColor:UIColor = UIColor.greenColor() 
    @IBInspectable var isAddButton:Bool = true 

    override func drawRect(rect: CGRect) { 
    var path = UIBezierPath(ovalInRect: rect) 
    fillColor.setFill() 
    path.fill() 

} }

我在學習本教程的同時瞭解到這一點http://www.raywenderlich.com/90690/modern-core-graphics-with-swift-part-1

ps.s.一旦你畫了一個圓形按鈕,你總是可以在屬性檢查器中選擇顏色。