2017-02-07 49 views

回答

1

这可能是如下

import UIKit 

class Rectangle:UIView{ 

    override func draw(_ rect: CGRect) { 
     let path = UIBezierPath(rect: rect) 
     path.move(to: CGPoint(x:0,y:rect.height)) 
     path.addLine(to: CGPoint(x:rect.width/2,y:rect.height/1.4)) 
     path.addLine(to: CGPoint(x:rect.width,y:rect.height)) 
     UIColor.red.setStroke() 
     path.stroke() 
    } 

} 

let rect=Rectangle(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) 
+0

谢谢你,但你可以请你给我的目标C一样简单? – hd1344

相关问题