开发者

create a non-rectangular UIView

开发者 https://www.devze.com 2023-01-31 20:43 出处:网络
I need to create a view (a uibutton) of strange shape. Is this possible with quartz2d? i used this code for buil my UIView subclass

I need to create a view (a uibutton) of strange shape. Is this possible with quartz2d? i used this code for buil my UIView subclass

- (void)drawRect:(CGRect)rect {

    // Drawing code
     CGContextRef context = UIGraphicsGetCurrentContext();
     CGContextMoveToPoint(context, 100, 100);
     CGContextAddLineToPoint(context, 150, 150);
     CGContextAddLineToPoint(context, 100, 200);
     CGContextAddLineToPoint(context, 50, 150);
     CGContextAddLineToPoint(context, 100, 100);
     CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
     CGContextFillPath(context);
}

but this is a draw inside a standard U开发者_如何学PythonIView (rectangular UIView)

0

精彩评论

暂无评论...
验证码 换一张
取 消