Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

How do I get that frosted glass gaussian blur?

The Storyboard has views Visual Effect View with Blur and Visual Effect View with Blur and Vibrancy. You can almost treat this like empty views.

So if you wanted a login dialog box that came up as a modal, but blur the background:

  • The login dialog box would have its own View Controller
  • Open the login dialog box as a modal
  • Make sure the modal segue is Over Current Context so the screen below doesn't vanish
  • Add a Visual Effect View with Blur behind your other views, serving as a background

Disallow rotation for onboarding


  • You're using UIPageViewController for onboarding
  • You have an UIViewController with a container that embeds the UIPageViewController
  • You present this UIViewController modally

The UIViewController container lets you do two things:

How to make a view circular

imageView.layer.cornerRadius = imageView.bounds.size.width / 2
chenr2 /
Last active August 29, 2015 14:25
YouTube v3 API: getting videos from a playlist
chenr2 /
Last active August 29, 2015 14:25
Swift: Demonstrating the Network Starter Kit for the Columbia iOS meetup

Demo of the Network Starter Kit

See Network Starter Kit.

This is the script for Tuesday's Columbia iOS meetup.

Some basics

Object Contains
chenr2 /
Last active February 2, 2016 16:32
Swift: dealing with keyboards

The keyboard keeps obscuring my content

TODO: WIP. Need to test next time I integrate this.

See Greg Heo's video ScrollView tutorial on

Text boxes can get covered up by the keyboard, especially on 3.5 inch screens (4s). The first step is to embed the page contents inside a UIScrollView.

@IBOutlet weak var scrollview: UIScrollView!
chenr2 /
Last active August 29, 2015 14:25
Swift: singleton
chenr2 /
Last active August 29, 2015 14:25
Swift: equatable protocol

How to tell if two things are the same

You want to iterate over an array of custom objects, and need to tell whether two objects are equal. You're not concerned with two objects being identical in memory, but equivalent based on your own definition.

class Student {
    var studentId = 0
    var firstName = "Bob"
chenr2 /
Created July 18, 2015 01:15
Swift: Count

How to count characters in a string

Just use count

chenr2 /
Last active August 29, 2015 14:25
Swift: JSON stringify

How to stringify JSON

This assumes you have SwiftyJSON.

Start with a Dictionary

let paramsDictionary = [
    "title": "foo",
 "description": "bar"