将 UIImageView 的区域涂黑或显示部分视图
有没有办法在不创建覆盖的 UIView 实例(使用此框架)并将其涂黑的情况下涂黑 UIImageView 的区域(由框架定义)?
是否有类似的方法可以显示 UIImageView
的一部分,而不使用 UIView 实例来遮蔽图像的其余部分?
Is there a way to black out a region (defined by a frame) of a UIImageView
without creating an overlaying UIView
instance (with this frame) and blacking that out?
Is there similarly a way to reveal part of a UIImageView
without using UIView instances to black out the rest of the image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将在这里作弊并建议您使用图层,因为它们重量轻。
对于第二部分,您可以考虑使用图层网格(黑色)。当用户触摸图像视图时,您可以从他触摸的区域中选取图层并将它们从超级图层(即图像视图的根图层)中删除。
I am going to cheat a bit here and suggest that you use layer as they are light weight.
For the second part you can consider using a grid of layers (black). When user touches the image view, you can pick the layers from the area he has touched and remove them from the super layer i.e. the image view's root layer.
您可以对 UIIMageView 进行子类化,并根据您的需要在 drawRectMethod 中进行绘制。
更新:
http://developer.apple.com/库/ios/#documentation/CoreGraphics/Reference/CoreGraphics_Framework/_index.html
you can subclass the UIIMageView and draw as per your needs in the drawRectMethod.
UPDATE:
http://developer.apple.com/library/ios/#documentation/CoreGraphics/Reference/CoreGraphics_Framework/_index.html