[source code] iOS Development with Swift Tutorial - 25 - Solid Shapes

+1 Bucky Roberts · February 5, 2015

import UIKit

class DrawExamples: UIView {

    override func drawRect(rect: CGRect) {
        let context = UIGraphicsGetCurrentContext()
        
        CGContextMoveToPoint(context, 50, 50)
        CGContextAddLineToPoint(context, 90, 130)
        CGContextAddLineToPoint(context, 180, 100)
        CGContextAddLineToPoint(context, 90, 60)
        CGContextAddLineToPoint(context, 50, 50)
        
        //To fill in a path
        CGContextSetFillColorWithColor(context, UIColor.redColor().CGColor)
        CGContextFillPath(context)
    }

}

Post a Reply

Replies

Oldest  Newest  Rating
0 Abdullah Nauman · February 6, 2015
Thanks, but I really think you should finish up the Android ones first. 
  • 1

iOS Development / Swift

107,293 followers
About

This forum is for questions, comments, and general discussion about iOS Development and Swift.

Links
Moderators
Bucky Roberts Administrator