Add MKUserTrackingBarButtonItem to UIView

I am using MKUserTrackingBarButtonItem to switch my MKMapView usertrackingMode.

  • Can I transfer this button from my toolbar and put it in a regular UIView?
  • Of course, I could implement the behavior of the button myself. Do you have resources for the icons used in this button?

MKUserTrackingBarButtonItem Icons

Thank you for your help.

+4
source share
3 answers

So, it seems that there is no way to directly add any element of the panel button to the UIView . We will need a subclass of UIToolbar to make the toolbar completely invisible. Override - (void)drawRect:(CGRect)rect and don't put anything, not even [super drawRect] . Then in init, run the following code:

 self = [super init]; self.backgroundColor = [UIColor clearColor]; self.opaque = NO; self.translucent = YES; return self; 

For more information, follow this link: Can't be transparent UIToolBar?

+5
source

Here's a link so you can create an image from a button. You probably want to do this because it comes in several states:

Create UIImage from shadow view while keeping alpha?

0
source

Starting with iOS 11, there is MKUserTrackingButton , which is a subclass of UIView .

0
source

Source: https://habr.com/ru/post/1380947/


All Articles