• Install
  • Tutorials
  • COSMOS
  • Examples
  • Forums
  • Docs
  • Install
  • Tutorials
  • COSMOS
  • Examples
  • Forums
  • Docs
Tutorials
>
COSMOS
>
Menu Shadow

Chapter 20
Menu Shadow

Tags
cosmos, animation

Estimated Time


Tutorials
>
COSMOS
>
Menu Shadow

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:

  1. A shadow object
  2. A reveal animation
  3. A hide animation

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.

Almost There

Seriously, we’re almost done.

You can get through this tutorial.

I believe in you.1

  1. I think I believe in myself too… This is a lot of writing!︎ ↩

Well done! Continue COSMOS?

  • Chapter 19
    Menu Selector

    Give the radial menu interaction and responsiveness with some programming wizardry.

  • Chapter 21
    The Menu – Pull it Together

    We've got all the components, let's get this beast put together now.

  • About
  • Features
  • Learn + Explore
  • Install C4
  • Examples
  • Tutorials
  • Docs
  • Connect
  • Forums
  • Medium
  • Twitter
  • Slack
  • Vimeo
  • GitHub
  • © 2016 C4
  • Terms of Use
  • Contact
  • Learn + Explore
  • Install C4
  • Examples
  • Tutorials
  • Docs
  • Connect
  • Forums
  • Medium
  • Twitter
  • Slack
  • Vimeo
  • GitHub
  • © 2016 C4
  • Terms of Use
  • Contact