user816604
user816604

Reputation:

Adding icon to map view

I would like to add an icon to the map view so that when people click on the icon, they see their current location.

I want to add the icon on the bottom left of this image:

enter image description here

How can I add that image to my map view?

I tried doing:

UIImage * l =  [UIImage imageNamed: @"location.png"];
UIImageView * lb = [[UIImageView alloc] initWithImage: l];
[lb setFrame: CGRectMake(0, 300, lb.frame.size.width, lb.frame.size.height)];
[self.mapview addSubview: lb];

Upvotes: 0

Views: 216

Answers (1)

Tyler
Tyler

Reputation: 371

I'd add it as a sibling to the map view instead. Doing so is safer, as there's no guarantee that the map view isn't manipulating its bounds when you pan/zoom (which would cause your icon to move as well).

[self.view addSubview:lb];

Upvotes: 2

Related Questions