import UIKit
class Shape {
var name : String?
var sides : Int?
var origin :CGPoint?
var lineColor :UIColor = UIColor.red
var fillColor :UIColor = UIColor.green
var lineWidth : CGFloat = 2
init(name : String, sides : Int, origin :CGPoint) {
self.name = name
self.sides = sides
self.origin = origin
}
func sayHello(){
print("Shape:\(name!),sides \(sides!), origin (\(origin!.x),\(origin!.y)) ")
}
}
class CzfView : UIView {
var shape : Shape?
override func draw(rect: CGRect) {
guard let s = shape else{
return
}
s.sayHello()
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let myShape = Shape(name:"BaseShape", sides: 0,origin: CGPoint(x:o, y:0))
let width = self.view.frame.size.width
let height = self.view.frame.size.height
let myView = CzfView(frame: CGRect(x: 0, y: 0, width: width, height: height))
myView.shape = myShape
self.view.addSubview(myView)
}
}
func drawBezierPath() {
let path = UIBezierPath()
let center : CGPoint = CGPoint(x:100, y:100)
let radius : CGFloat = 80
path.addArc(withCenter: center, radius: radius, startAngle: 0, endAngle: CGFloat.pi*2, clockwise: true)
path.lineWidth = 5
UIColor.red.setstroke()
path.stroke()
}