I am new to iOS and I have an UIImageView which I want to put a marker or bubble when user tapped on the image. Any way to put a marker or bubble on UIImageView?
Asked
Active
Viewed 690 times
2 Answers
3
You could add a tap gesture to your imageView
and when you tap on it add a bubble image inside it on the desired place.
So something like this:
- Create a
UIImageView
- Add a
UITapGestureRecognizer
to it - In the function for the
UITapGestureRecognizer
add a newUIImageView
inside the first one
Code example:
let tap = UITapGestureRecognizer(target: self, action: #selector(imageTapped))
tap.numberOfTapsRequired = 1
imageVIew.addGestureRecognizer(tap)
imageVIew.isUserInteractionEnabled = true
func imageTapped() {
let buble = UIImageView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
buble.image = UIImage(named: "buble")
imageVIew.addSubview(buble)
}
Sample project that you can continue working with:
Here is a sample project that you can try with that does what I have described above.

Rashwan L
- 38,237
- 7
- 103
- 107
-
Can You please tell me after putting bubble image i want to save as pdf with bubble image is it possible? – Vishal Parmar Feb 22 '19 at 07:07
-
@VishalParmar, checkout [this post](https://stackoverflow.com/questions/47710554/swift-uiimage-convert-as-pdf) it might help you. – Rashwan L Mar 03 '19 at 06:34
1
You should just create a new view (can be UIView or another UIImageView) and add it as a subview of that image view.

Giovanni Filaferro
- 113
- 7