Chapter 19
Menu Selector
Give the radial menu interaction and responsiveness with some programming wizardry.
After the last chapter’s marathon of coding, this one is a cinch. We need a shadow to appear underneath the menu, so we need 3 things:
Keeping consistent with the various layers we’re creating as separate CanvasController
objects, we’re going to do the same here.
In MenuShadow.swift
simply paste the following into the body of the class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var reveal : ViewAnimation?
var hide : ViewAnimation?
public override func setup() {
canvas.frame = Rect(UIScreen.mainScreen().bounds)
canvas.backgroundColor = black
canvas.opacity = 0.0
createShadowAnimations()
}
func createShadowAnimations() {
reveal = ViewAnimation(duration:0.25) {
self.canvas.opacity = 0.44
}
reveal?.curve = .EaseOut
hide = ViewAnimation(duration:0.25) {
self.canvas.opacity = 0.0
}
hide?.curve = .EaseOut
}
That’s it.
Since this class is so simple, we’re not going to test it. We’ll see its effect in the next chapter when we pull the entire menu together.
Here’s a copy of the MenuShadow.swift.
Seriously, we’re almost done.
You can get through this tutorial.
I believe in you.1
I think I believe in myself too… This is a lot of writing!︎ ↩