在视图中显示 UIBezierPath [英] Showing UIBezierPath on view
本文介绍了在视图中显示 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屋!
查看全文