我有一个我绘制的UIBezierPath
数组,还有一个UIImageView
,所有这些都放在UIView
上。当我绘制一个UIBezierPath
并将其保存到数组中,然后添加一个UIImageView
,然后绘制另一条路径时,第二条路径将出现在图像后面。 UIBezierPath
是否有诸如 bringSubViewToFront:
之类的东西?
- (void)drawRect:(CGRect)rect
{
for(int a=0; a<_pathArray.count; a++) {
[(UIColor )[_colorArray objectAtIndex:a] setStroke];
[(UIBezierPath)[_pathArray objectAtIndex:a] strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
}
其中 _colorArray
是每个路径的颜色数组,_pathArray
是 UIBezierPath
的数组。我将 UIImageView
插入到 View 上,然后我想要做的是能够在整个 UIView
上绘制(包括在 UIImageView 顶部)
)。
最佳答案
所有 subview 将始终绘制在 super View 的“顶部”。贝塞尔曲线路径不是 subview ,它们是作为 View 的一部分绘制的,因此它们始终位于 subview 后面。
您可以将当前添加到 ImageView 的图像渲染到当前上下文中(在drawRect
期间)。或者,您可以将 ImageView 添加到绘制贝塞尔曲线路径的 View 后面(通过将它们添加到同一 super View ,或者添加绘制贝塞尔曲线的新同级 View 。
关于iphone - 分层 UIImageView 和 UIBezierPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18295777/