Я слишком долго был вне игры. Кто-нибудь знает, что здесь происходит?
Вот YouTube видео , которое я смотрел, для справки.
Проверьте ошибки здесь
Вот код:
import UIKit
class DrawExamples: UIView {
override func drawRect(rect: CGRect) {
// context is the object used for drawing
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 3.0)
CGContextSetStrokeColorWithColor(context, UIColor.purpleColor().CGColor)
/*
//straight line
CGContextMoveToPoint(context, 30, 30)
CGContextAddLineToPoint(context, 150, 320)
*/
CGContextMoveToPoint(context, 50, 50)
CGContextAddLineToPoint(context, 90, 130)
CGContextAddLineToPoint(context, 180, 100)
CGContextAddLineToPoint(context, 90, 60)
CGContextAddLineToPoint(context, 90, 130)
//Actually draw the path
CGContextStrokePath(context)
}
}