I have this UIImage in a UIImageView:
我在UIImageView中有这个UIImage:
I want it so that when a user touches inside of any box, it fills with a blue color.
我想要它,以便当用户触摸任何盒子内部时,它会填充蓝色。
This is just an example... the actual image I am going to use is not squares, but a more complex line drawing, so drawing it with code would be extremely complex.
这只是一个例子......我要使用的实际图像不是正方形,而是更复杂的线条图,因此用代码绘制它将非常复杂。
What is the best way to accomplish this?
完成此任务的最佳方法是什么?
2 个解决方案
#1
1
You can go with flood fill Algorithm.
你可以使用泛洪填充算法。
That is the best way to fill any image.
这是填充任何图像的最佳方式。
there is some links for that
有一些链接
http://en.wikipedia.org/wiki/Flood_fill
http://en.wikipedia.org/wiki/Flood_fill
and get sample code from here
并从这里获取示例代码
洪水填充
#2
0
Use UIView
and implement its drawrect method to show the colors.Use QuartzCore
and CoreGraphics
to draw. Implement the touch with drawing of color to the view.
使用UIView并实现其drawrect方法来显示颜色。使用QuartzCore和CoreGraphics绘制。在视图中使用颜色绘制实现触摸。
#1
1
You can go with flood fill Algorithm.
你可以使用泛洪填充算法。
That is the best way to fill any image.
这是填充任何图像的最佳方式。
there is some links for that
有一些链接
http://en.wikipedia.org/wiki/Flood_fill
http://en.wikipedia.org/wiki/Flood_fill
and get sample code from here
并从这里获取示例代码
洪水填充
#2
0
Use UIView
and implement its drawrect method to show the colors.Use QuartzCore
and CoreGraphics
to draw. Implement the touch with drawing of color to the view.
使用UIView并实现其drawrect方法来显示颜色。使用QuartzCore和CoreGraphics绘制。在视图中使用颜色绘制实现触摸。