2017年5月3日 | Leave a comment 问题: uiview如何绘画 解决: class View1 : UIView { override func draw(_ rect: CGRect) { print("YKFilterCategoryCell draw") super.draw(rect) let y = self.frame.size.height let p = UIBezierPath() p.move(to: CGPoint(x:0,y:y)) p.lineWidth = 0.5 UIColor.gray.set() p.addLine(to: CGPoint(x:self.frame.size.width, y:y)) p.stroke() } } 1234567891011121314151617 class View1 : UIView { override func draw(_ rect: CGRect) { print("YKFilterCategoryCell draw") super.draw(rect) let y = self.frame.size.height let p = UIBezierPath() p.move(to: CGPoint(x:0,y:y)) p.lineWidth = 0.5 UIColor.gray.set() p.addLine(to: CGPoint(x:self.frame.size.width, y:y)) p.stroke() } } 参考O: