• Stars
    star
    2,125
  • Rank 21,718 (Top 0.5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Control Center-esque control with blurred background and toggle animations.

RNFrostedSidebar

Add your own Control Center-esque UI to your app to work as navigation or even toggle different settings. Blend right into the new iOS 7 design with animated blurs, flat design, and custom animations.

This project is another UI control built after finding some inspiration on Dribbble. The original design was created by Jakub Antalik.

For some thoughts on live blur in iOS apps, check out my blog post.

You'll notice that this control's use of blur does not match Jakub's original design exactly. In the original design the background of the buttons is blurred, while the overlay of the control is simply shaded. There have been attempts at recreating this effect, but it is rumored that live-blurring takes place at a much lower level on the GPU and there would be security concerns were we to have access.

Apple is being a little deceptive with their use of blurring in iOS 7. Bottom line, don't animate blurs in your designs.

If you examine the source of this project you'll see that I'm actually cheating to get the blur layer to animate overtop the original view.

Installation

The preferred method of installation is with CocoaPods. Just add this line to your Podfile.

pod 'RNFrostedSidebar', '~> 0.2.0'

Or if you want to install manually, drag and drop the RNFrostedSidebar .h and .m files into your project. To get this working, you'll need to include the following frameworks in Link Binary with Libraries:

  • QuartzCore
  • Accelerate

Usage

The simplest usage is to create a list of images, initialize a RNFrostedSidebar object, then call the -show method.

NSArray *images = @[
                    [UIImage imageNamed:@"gear"],
                    [UIImage imageNamed:@"globe"],
                    [UIImage imageNamed:@"profile"],
                    [UIImage imageNamed:@"star"]
                    ];

RNFrostedSidebar *callout = [[RNFrostedSidebar alloc] initWithImages:images];
callout.delegate = self;
[callout show];

If you use RNFrostedSidebar with a UINavigationController, you can push another UIViewController after selecting a button. Simply initialize it in sidebar:didTapItemAtIndex:, then push it onto the navigation stack after dimissing the sidebar with -dismissAnimated:completion:.

- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index {
    if (index == 1) {
        [sidebar dismissAnimated:YES completion:^(BOOL finished) {
            if (finished) {
                UIViewController *secondVC = [[UIViewController alloc] init];
                [self.navigationController pushViewController:secondVC animated:YES];
            }
        }];
    }
}

Customization

I've exposed a healthy amount of options for you to customize the appearance and animation of the control.

- (instancetype)initWithImages:(NSArray *)images selectedIndices:(NSIndexSet *)selectedIndices;

Use the parameter selectedIndices to add pre-selected options. Without using the init method below there wont be any visualization of selection. But, you will get the proper enabled/disabled BOOL in the delegate -sidebar:didEnable:itemAtIndex: method.

- (instancetype)initWithImages:(NSArray *)images selectedIndices:(NSIndexSet *)selectedIndices borderColors:(NSArray *)colors;

Use the parameter borderColors to add border effect animations when selecting and deselecting a view.

@property (nonatomic, assign) CGFloat width;

The width of the blurred region. Default 150.

@property (nonatomic, assign) BOOL showFromRight;

Toggle showing the control from the right side of the device. Default NO.

@property (nonatomic, assign) CGFloat animationDuration;

The duration of the show and dismiss animations. Default 0.25.

@property (nonatomic, assign) CGSize itemSize;

The size of the item views. Default is width: 75, height: 75.

@property (nonatomic, strong) UIColor *tintColor;

The tint color of the blur. This can be a tricky property to set. I recommend using the provided alpha. Avoid using solid colors with an alpha of 1. Default white: 0.2, alpha: 0.73.

@property (nonatomic, strong) UIColor *itemBackgroundColor;

The background color for item views. Note: This property must be set with either colorWithWhite:alpha or colorWithRed:green:blue:alpha or it will crash. This is for highlight effects on tapping so the control can derive a darker background when highlighted. Default white: 1, alpha 0.25.

@property (nonatomic, assign) NSUInteger borderWidth;

The border width for item views. Default 2.

@property (nonatomic, weak) id <RNFrostedSidebarDelegate> delegate;

An optional delegate to respond to selection of item views. Optional delegate methods, provided by George Villasboas, include:

- (void)sidebar:(RNFrostedSidebar *)sidebar willShowOnScreenAnimated:(BOOL)animatedYesOrNo;
- (void)sidebar:(RNFrostedSidebar *)sidebar didShowOnScreenAnimated:(BOOL)animatedYesOrNo;
- (void)sidebar:(RNFrostedSidebar *)sidebar willDismissFromScreenAnimated:(BOOL)animatedYesOrNo;
- (void)sidebar:(RNFrostedSidebar *)sidebar didDismissFromScreenAnimated:(BOOL)animatedYesOrNo;
- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index;
- (void)sidebar:(RNFrostedSidebar *)sidebar didEnable:(BOOL)itemEnabled itemAtIndex:(NSUInteger)index;

Credits

UI Control structure and View Controller containment practices adopted from Matthias Tretter.

Sample icons provided by Pixeden.

The blur algorithm comes from WWDC 2013's session 208, "What's New in iOS User Interface Design".

Apps

If you've used this project in a live app, please let me know! Nothing makes me happier than seeing someone else take my work and go wild with it.

Contact

License

See LICENSE.

More Repositories

1

RNGridMenu

A grid menu with elastic layout, depth of field, and realistic animation.
Objective-C
1,282
star
2

RNBlurModalView

Add depth to your alerts.
Objective-C
830
star
3

RNRippleTableView

A custom table view with highly detailed ripple animations.
Objective-C
390
star
4

RNThemeManager

Easily manage themes and respond to theme changes by updating views in real time.
Objective-C
322
star
5

RNSwipeViewController

Swipe in view controllers from off-screen similar to Check the Weather.
Objective-C
293
star
6

HackerNewsReader

A small, read-only app for Hacker News.
Objective-C
261
star
7

WeatherKit

A quick and elegant solution to gathering local weather data.
Objective-C
166
star
8

UITableViewController-Containment-Demo

This is a sample project showing how to contain a UITableViewController in another VC with a Search Bar + Display Controller working as if it were all in a UITableViewController.
Objective-C
135
star
9

RNExpandingButtonBar

iOS UI widget that mimics the famous button used by the app Path.
Objective-C
126
star
10

RNTextStatistics

A category on NSString to gather advanced statistics on text.
Objective-C
124
star
11

RNBoilerplate

A bundle of my necessary frameworks, libraries, helpers, and settings for each Xcode project with configurable options.
Objective-C
106
star
12

SimpleWeather

A personal weather app I'm building in the open.
Swift
83
star
13

RNSwipeBar

Custom iOS widget to swipe a tab bar from the bottom of the screen
Objective-C
66
star
14

RNAvatarLogin

A simple way to autocomplete Gravatar icons for text fields.
Objective-C
57
star
15

Swift-CoreData

An extremely simple Core Data backed Swift app
Swift
55
star
16

PopDemos

Some demos of Facebook's Pop library made for a RayWenderlich.com tech talk.
Objective-C
53
star
17

TransitionExample

Testing UIViewControllerAnimatedTransitioning
Objective-C
42
star
18

World-Cup-Matches

Very simple app to keep an eye on World Cup 2014 matches.
Objective-C
39
star
19

Metro-Lights

A dark Xcode theme inspired by City Lights for Atom.
34
star
20

IGListKit-Binding-Guide

Starter and finished project for binding guide.
Objective-C
33
star
21

Xcode-Empty-Application

Adding the Empty Application template back to Xcode
30
star
22

UISVC-Compatibility-Demo

UISplitViewController setup that works on iOS 7 with all devices (iPhones + iPads).
Swift
30
star
23

VectorKit

A vector library and playground
Swift
29
star
24

D3Kit

An easy to use iOS library to access the Diablo 3 API.
Objective-C
28
star
25

OneNews-Swift

A work-in-progress universal iOS app for reading Hacker News, Designer News, and Product Hunt.
Objective-C
26
star
26

From-Scratch-Guides

Collection of guides & tutorials about building software from nothing.
25
star
27

WatchKit-by-Tutorials

Repository for all sample code in the upcoming WatchKit by Tutorials book from Ray Wenderlich.
Objective-C
20
star
28

IGListKit-Benchmarks

Benchmark tests for IGListKit
Swift
17
star
29

RNMDParser

Sample application experimenting with Obj-C Markdown parsing.
Objective-C
16
star
30

BottleRocket

An experimental CLI tool for generating normalized Swift models from example JSON responses.
Swift
12
star
31

New-Awesome-Blog

Showing off my awesome blog!
HTML
11
star
32

leadership

[WIP] My thoughts, principles, and resources on leadership.
11
star
33

NSString-RNSynonyms

A fast and lightweight solution to finding synonyms for words, built as a category on NSString.
Objective-C
11
star
34

RNTableView

A recreation of UITableView with only the bear essentials. Use this to start a highly customized UITableView.
Objective-C
11
star
35

WatchKit-Threading

A really simple demo app showing that threading in WatchKit works.
Objective-C
10
star
36

Arduino-HomeKit

HTML
9
star
37

RWDevCon-View-Controller-Transitions

Objective-C++
8
star
38

RNCardStreamController

A vertical section and cell navigation control inspired by Facebook Paper.
Objective-C
8
star
39

Armory-for-Diablo-3

Source code for my Armory app that is awaiting Apple approval.
Objective-C
7
star
40

WeatherExample

Building a Weather app example using ReactiveCocoa for raywenderlich.com
Objective-C
6
star
41

status-checklists

Action to that updates Issue state with checklists
TypeScript
5
star
42

create-child-issues

Action to generate child issues with labels.
JavaScript
5
star
43

Crateless

https://itunes.apple.com/us/app/crateless/id563997439?ls=1&mt=8
Objective-C
5
star
44

.github-template

4
star
45

Playground

Link: https://github.com mention: @rnystrom
3
star
46

RNNumberedTextView

Easily add customizable line numbers to UITextView.
Objective-C
2
star
47

issue-actions

WIP actions to sync parent and child issues.
JavaScript
2
star
48

M3Demo

Objective-C
2
star
49

HackerNews-iOS

Objective-C
1
star
50

Blog

Nothing special.
CSS
1
star
51

dotfiles

1
star
52

Read-Write-Protection-Perf

Teeny tiny profiling of different ways to protect mutations in your objects.
Objective-C
1
star
53

SunlightTest

Sample app to test background and text colors in sunlight
Objective-C
1
star