在代码生成的UIView上绘制UIBezierPath
我有一个 UIView在运行时添加了代码。 我想在其中画一个UIBezierPath,但这是否意味着我必须重写drawRectUIView? 还是有另一种在定制产品上绘图的方法 UIView? 这是用于生成的代码UIView: UIView* shapeView = [[UIView alloc]initWithFrame:CGRectMake(xOrigin,yOrigin+(i*MENU_BLOCK_FRAME_HEIGHT), self.shapeScroll.frame.size.width, MENU_BLOCK_FRAME_HEIGHT)]; shapeView.clipsToBounds = YES; 这是创建和返回a的函数UIBezierPath: - (UIBezierPath*)createPath { UIBezierPath* path = [[UIBezierPath alloc]init]; [path moveToPoint:CGPointMake(100.0, 50.0)]; [path addLineToPoint:CGPointMake(200.0,50.0)]; [path addLineToPoint:CGPointMake(200.0, 200.0)]; [path addLineToPoint:CGPointMake(100.0, 200.0)]; [path closePath]; return path; }