在视图上显示UIBezierPath [英] Showing UIBezierPath on view

查看:132
本文介绍了在视图上显示UIBezierPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的方法之一,我有这个代码:

In one of my methods i have this code:

-(void)myMethod {   
   UIBezierPath *circle = [UIBezierPath
                       bezierPathWithOvalInRect:CGRectMake(75, 100, 200, 200)];  
}

如何让它在视图上显示?

How do i get it to show on the view?

我试过addSubview,但它给了一个不兼容的类型错误,因为它期待一个UIView。

I tried addSubview but it gave me an incompatible type error because its expecting a UIView.

我确定这必须很简单。

感谢

推荐答案

您可以使用 fill stroke 视图的 drawInRect:实现:

You can draw it using either fill or stroke methods for example in custom view's drawInRect: implementation:

- (void)drawRect:(CGRect)rect {
    // Drawing code
    UIBezierPath *circle = [UIBezierPath
                    bezierPathWithOvalInRect:CGRectMake(75, 100, 200, 200)];  
    [circle fill];
}

这篇关于在视图上显示UIBezierPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆