Swift:UIGraphics Drawing on UIView

From Hawk Wiki
Revision as of 04:13, 23 March 2015 by Hall (Talk | contribs) (Created page with "===Swift: Tutorial Drawing Graphic=== See http://www.techotopia.com/index.php/An_iOS_8_Swift_Graphics_Tutorial_using_Core_Graphics_and_Core_Image ===Swift:Create Custom UICol...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Swift: Tutorial Drawing Graphic

See http://www.techotopia.com/index.php/An_iOS_8_Swift_Graphics_Tutorial_using_Core_Graphics_and_Core_Image

Swift:Create Custom UIColor

let swiftColor = UIColor(red: 1, green: 165/255, blue: 0, alpha: 1)

Swift: How to make UIGraphics context background transparent

If you want to set a transparent background of the content you are drawing.

// UIGraphics draw transparent background context
@IBOutlet weak var histogramView: HistogramView!
override func viewWillAppear(animated: Bool) {
    histogramView.opaque = false 
    histogramView.backgroundColor = UIColor.clearColor()
}
class HistogramView: UIView {
    override func drawRect(rect: CGRect) {
        // draw content
        let context = UIGraphicsGetCurrentContext()
        CGContextClearRect(context, rect)
    }
}