1
00:00:08,020 --> 00:00:12,760
Hey guys this is Caleb with Dev slopes dot com and in this very short video we're going to set up our

2
00:00:12,850 --> 00:00:17,990
map pen so that it is not red but instead is orange to match the theme of our application.

3
00:00:18,160 --> 00:00:20,310
So let's get started right away.

4
00:00:20,320 --> 00:00:26,290
Go ahead and pull open your X code project and we're going to actually use an M-K map view delegate

5
00:00:26,890 --> 00:00:31,030
method that is just built in called view for annotation.

6
00:00:31,030 --> 00:00:36,470
And that's basically going to allow us to customize the appearance of that pin that gets dropped.

7
00:00:36,730 --> 00:00:42,220
So go ahead and type view for annotation and it should show up right here at the top of the results.

8
00:00:42,220 --> 00:00:49,330
Press enter and inside of this what we're going to do is we're going to customize our pin to be a custom

9
00:00:49,330 --> 00:00:51,100
color which is very cool.

10
00:00:51,100 --> 00:00:55,580
So go ahead and type var pin annotation.

11
00:00:55,660 --> 00:00:59,270
And it's going to be equal to M-K pin annotation view.

12
00:00:59,500 --> 00:01:05,380
Now to make one of those we have to pass in two things an annotation and a reuse identifier.

13
00:01:05,500 --> 00:01:06,000
OK.

14
00:01:06,160 --> 00:01:12,700
The annotation of course is going to be our annotation and the reuse identifier is going to be drop

15
00:01:12,710 --> 00:01:14,330
a pin.

16
00:01:16,310 --> 00:01:20,500
Make sure that you're using the right identifier there.

17
00:01:20,810 --> 00:01:25,340
So next what we're going to do is we're going to set the color to be orange which is exactly what we

18
00:01:25,340 --> 00:01:25,670
want.

19
00:01:25,670 --> 00:01:36,550
So type pin pin pin Dippin Dots penitente color Well it's giving me an error here what's the deal.

20
00:01:36,560 --> 00:01:39,860
It's a problem.

21
00:01:41,210 --> 00:01:42,680
Oh that's because it's not called Pen.

22
00:01:42,770 --> 00:01:46,270
It's called Pin annotation pin to color.

23
00:01:46,490 --> 00:01:51,230
And we need to set it to be equal to you eye color dot orange.

24
00:01:51,230 --> 00:01:57,380
And you know what we could do that or we could do the really cool new color little feature in swift

25
00:01:57,620 --> 00:02:02,540
where you can literally click here click here and now I can choose my color so I'm going to choose the

26
00:02:02,540 --> 00:02:05,780
exact color from my interface builder.

27
00:02:05,780 --> 00:02:07,180
Really really cool.

28
00:02:07,670 --> 00:02:08,470
So there's that.

29
00:02:08,540 --> 00:02:11,030
The pin has been given the proper color.

30
00:02:11,030 --> 00:02:15,810
Now we need to do is we need to set it so that the pin annotation animates when it drops to the map

31
00:02:15,810 --> 00:02:16,040
view.

32
00:02:16,040 --> 00:02:22,070
So go ahead and type pin annotation animates drop and set that to be equal to true.

33
00:02:22,490 --> 00:02:29,130
Now that those two important properties are set we can go ahead and return pin annotation.

34
00:02:29,630 --> 00:02:32,000
Let's go ahead and build and run this to see if it works.

35
00:02:33,620 --> 00:02:34,590
Ok I'm building it.

36
00:02:34,600 --> 00:02:36,010
It's launching.

37
00:02:36,520 --> 00:02:37,510
And let's see how we do.

38
00:02:41,740 --> 00:02:42,330
All right.

39
00:02:42,580 --> 00:02:47,620
So it looks like it's now dropping an orange pen where our location is which is you know it's OK that's

40
00:02:47,620 --> 00:02:51,950
not exactly what I want but let's try dropping a pin where we click double click.

41
00:02:52,000 --> 00:02:52,750
Awesome.

42
00:02:52,750 --> 00:02:53,680
Let's do it again.

43
00:02:53,770 --> 00:02:56,420
Double click double click.

44
00:02:56,530 --> 00:02:56,890
Awesome.

45
00:02:56,900 --> 00:02:58,080
OK so that's working.

46
00:02:58,080 --> 00:02:58,990
It looks great.

47
00:02:59,200 --> 00:03:03,190
But I want to prevent it from dropping a pen where my user location is.

48
00:03:03,280 --> 00:03:06,010
Thankfully there's a special class so to do that.

49
00:03:06,010 --> 00:03:12,730
We're going to go ahead and we're going to type if annotation is M-K user location.

50
00:03:13,090 --> 00:03:18,710
That's the blue dot we're going to go ahead and return whip's return nil.

51
00:03:18,890 --> 00:03:20,280
OK that means it's going to return.

52
00:03:20,290 --> 00:03:21,300
No annotation view.

53
00:03:21,300 --> 00:03:24,380
It's not going to update the pin or set it to be an orange pin.

54
00:03:24,400 --> 00:03:28,840
Let's build and run it and double check that that works exactly as we were hoping.

55
00:03:29,260 --> 00:03:29,940
Oh and you know what.

56
00:03:29,980 --> 00:03:33,050
I think it's telling me that I should change it to elect constant.

57
00:03:33,070 --> 00:03:34,700
That's probably true.

58
00:03:35,360 --> 00:03:36,270
Change that to a lot.

59
00:03:36,270 --> 00:03:42,130
We're not actually modifying anything other than some of the properties so change it to a constant that's

60
00:03:42,130 --> 00:03:42,700
cool.

61
00:03:42,700 --> 00:03:44,520
All right cool so our location is back.

62
00:03:44,530 --> 00:03:46,380
Nice little pulsating thing there.

63
00:03:46,480 --> 00:03:48,750
And now we can drop a pin wherever we want.

64
00:03:48,760 --> 00:03:50,830
And it centers on the map view.

65
00:03:50,830 --> 00:03:51,670
Amazing.

66
00:03:51,680 --> 00:03:56,810
So that is exactly what we were supposed to do make a custom pin that drops on the screen.

67
00:03:57,070 --> 00:03:58,090
That's very very cool.

68
00:03:58,090 --> 00:04:03,580
So in the next video we're going to go ahead and we're going to start animating up that view that we

69
00:04:03,580 --> 00:04:05,290
put at the very bottom of our map.

70
00:04:05,290 --> 00:04:06,440
Did you forget about that.

71
00:04:06,760 --> 00:04:13,000
It's down here hiding and when whenever we double tap and drop a pin it's going to animate up and then

72
00:04:13,000 --> 00:04:19,090
we're going to start processing adding a collection view and doing much more adding in our cool functionality

73
00:04:19,090 --> 00:04:24,150
for downloading photos so head over to the next video and we'll start on animating up that view.
