Hey guys this is Caleb with slopes dot com and in this very short video we're going to set up our map
you pen so that it is not red but instead is orange to match the theme of our application.
So let's get started right away.
Go ahead and pull open your X code project and we're going to actually use an M.K. map view delegate
method that is just built in called view for annotation.
And that's basically going to allow us to customize the appearance of that pin that gets dropped.
So go ahead and type view for annotation and it should show up right here the top of the results press
enter and inside of this what we're going to do is we're going to customize our pin to be a custom color
which is very cool.
So go ahead and type var pin annotation.
And it's going to be equal to M-K pin annotation view.
Now to make one of those we have to pass in two things an annotation and a reuse identifier.
OK.
The annotation of course is going to be our annotation and the reuse identifier is going to be drop
a pin.
Make sure that you're using the right identifier there.
So next what we're going to do is we're going to set the color to be orange which is exactly what we
want.
So type pin pin pin Dippin Dots pin tint color.
Well it's giving me an error here what's the deal.
It's a problem.
Oh that's because it's not called pin.
It's called Pin annotation pin 10 color and we need to set it to be equal to you eye color dot orange.
And you know what we could do that or we could do the really cool new color litteral feature in swift
where you can literally click here click here and now I can choose my color so I'm going to choose the
exact color from my interface builder.
Really really cool.
OK so there's that.
The pin has been given the proper color.
Now we need to do is we need to set it so that the pin annotation animates when it drops to the map
view.
So go ahead and type pin annotation animates drop and set that to be equal to true.
Now that those two important properties are set we can go ahead and return pin annotation.
Let's go ahead and build and run this to see if it works.
I'm building it.
It's launching.
And let's see how we do.
All right.
So it looks like it's now dropping an orange pen where our location is which is you know it's OK that's
not exactly what I want but let's try dropping a pin where we click double click.
Awesome.
Let's do it again.
Double click double click.
Awesome.
OK so that's working.
That looks great.
But I want to prevent it from dropping a pen where my user location is.
Thankfully there's a special class so to do that.
We're going to go ahead and we're going to type if annotation is M-K user location.
That's the blue dot we're going to go ahead and return whip's return nil.
OK that means it's going to return.
No annotation view it's not going to update the pin or set it to be an orange pin.
Let's build and run it and double check that that works exactly as we were hoping.
Oh and you know what.
I think it's telling me that I should change it to let constant.
That's probably true.
Change that too a lot.
We're not actually modifying anything other than some of the properties so change it to a constant that's
cool.
All right cool so our location is back.
Nice little pulsating thing there.
And now we can drop a pin wherever we want.
And it centers on the map view.
Amazing.
So that is exactly what we were supposed to do make a custom pin that drops on the screen.
That's very very cool.
So in the next video we're going to go ahead and we're going to start animating up that view that we
put at the very bottom of our map.
Did you forget about that.
It's down here hiding and when whenever we double tap and drop a pin it's going to animate up and then
we're going to start processing adding a collection view and doing much more adding in our cool functionality
for downloading photos so head over to the next video and we'll start on animating up that view.