Recently Added iOS Source Code Examples

More >
  • UzysAnimatedGifLoadMore features:
-simple to use.
-Support CocoaPods.
-ARC Only (if your project doesn't use ARC , Project -> Build Phases Tab -> Compile Sources Section -> Double Click on the file name Then add -fno-objc-arc to the popup window.)

Copy over the files libary folder to your project folder ## Usage ###Import header.
#import "UIScrollView+UzysAnimatedGifLoadMore.h"

adding addLoadMoreActionHandler
- (void)viewDidLoad
    __weak typeof(self) weakSelf =self;
    [self.tableView addLoadMoreActionHandler:^{
        [weakSelf insertRowAtTop];

programmatically trigger LoadMore:
[_tableView triggerLoadMoreActionHandler];

stop LoadMore Activity Animation:
[_tableView stopLoadMoreAnimation];

Progress : Animated GIF , Loading : Animated GIF
- (void)addLoadMoreActionHandler:(actionHandler)handler
                ProgressImagesGifName:(NSString *)progressGifName
                 LoadingImagesGifName:(NSString *)loadingGifName

Progress : Animated GIF , Loading : UIActivitiyIndicator
- (void)addLoadMoreActionHandler:(actionHandler)handler
                ProgressImagesGifName:(NSString *)progressGifName

Progress : Array images , Loading : UIActivitiyIndicator
- (void)addLoadMoreActionHandler:(actionHandler)handler
                       ProgressImages:(NSArray *)progressImages

Progress : Array images , Loading : Array images
- (void)addLoadMoreActionHandler:(actionHandler)handler
                       ProgressImages:(NSArray *)progressImages
                        LoadingImages:(NSArray *)loadingImages

see the example project for more detail.



    Add LoadMore using animated GIF to any scrollView with just simple code。

  • Example Setup

Clone the repo and drag the MMParallaxPresenter folder into your project. This should include MMHeaderUIView.h/.m, MMParallaxPage.h/.m, and MMParallaxPresenter.h/.m
Drag and drop a UIScrollView into your Interface Builder and under the custom class section, subclass your UIScrollView to MMParallaxPresenter
Now add: @property (weak, nonatomic) IBOutlet MMParallaxPresenter *mmParallaxPresenter; to your list of properties and dont forget to link it up in your Interface Builder
Add a MMParallaxPage to the MMScrollPresenter. To do this, you have three init methods at your disposal. All the default views are shown in the above gif in this order:

-(id)initWithScrollFrame:(CGRect)scrollFrame withHeaderHeight:(int)height andContentText:(NSString *)contentText;

-(id)initWithScrollFrame:(CGRect)scrollFrame withHeaderHeight:(int)height withContentText:(NSString *)contentText andContextImage:(UIImage *)image;

-(id)initWithScrollFrame:(CGRect)scrollFrame withHeaderHeight:(int)height andContentView:(UIView *)contentView;
Here is the snippet of code slightly modified from the example app included in the repo. This shows how to initalize and setup a page and add it to your presenter:

MMParallaxPage *page1 = [[MMParallaxPage alloc] initWithScrollFrame:self.mmParallaxPresenter.frame withHeaderHeight:150 andContentText:[self sampleText]];
[page1.headerLabel setText:@"Section 1"];
[page1.headerView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"stars.jpeg"]]];

[self.scrollView addParallaxPageArray:@[page1]];



    iOS Custom UIScrollView Class to display static text / views with a vertical parallax effect。

  • JVFloatingDrawer is a floating style drawer navigation. There is a growing number of applications leveraging the drawer pattern. Most share a similar look and feel. With JVFloatingDrawer we aimed to bring a facelift to the conventional setup.


JVFloatingDrawer is very easy to use. Below is all that is needed to get going.

JVFloatingDrawerViewController *drawerViewController = [[JVFloatingDrawerViewController alloc] init];

// Assign to your own view controllers
drawerViewController.leftViewController   = leftDrawerViewController;
drawerViewController.rightViewController  = rightDrawerViewController;
drawerViewController.centerViewController = centerViewController;

self.drawerViewController.backgroundImage = [UIImage imageNamed:@"background-image-example.jpg"];

drawerViewController.animator = [[JVFloatingDrawerSpringAnimator alloc] init];
To see an example implementation of this run the example project. Clone the repo, run pod install from the Example directory, and open up Example/JVFloatingDrawer.xcworkspace.


JVFloatingDrawer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "JVFloatingDrawer"



    An easy to use floating drawer view controller。

  • This is a layout that clones the interaction of going through cities in the City Guide App. (this app is #3 for the top iOS app animations on the raywenderlich

To use this simply drop it in as a class in the storyboard or nib when you create your collection view. or you can instantiate it in code and give it your collection view(via initWithFrame:collectionViewLayout: or just set the layout propery of the collection View. and you can use your collection View as you always do.

One important this for this layout is that in the datasource protcol to specify the number of cards you must use numberOfSectionsInCollectionView: , and for collectionView:numberOfItemsInSection: you must always return 1.

also note that the itemsize is computed by the layout to be "appropriate" to the size of the collection view itself so setting it won't do anything.



    his is a layout that clones the interaction of going through city "cards" in the City Guide App。

  • Usage
For a working implementation, Have a look at the Sample Project - sample

Add folder YALSunnyRefreshControll to your project.
Implement header and setup YALSunnyRefreshControl as a property.
Init and associate YALSunnyRefreshControl with your UITableView or UICollectionView.
Add images from Images.xcassets folder in Sample Project.
#import "YALSunnyRefreshControl.h"

@property (nonatomic,strong) YALSunnyRefreshControl *sunnyRefreshControl;

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupRefreshControl];


    self.sunnyRefreshControl = [YALSunnyRefreshControl attachToScrollView:self.tableView



    // start loading something


    [self.sunnyRefreshControl endRefreshing];
To customize drawables you can change:

sun.png - Sun image
sky.png - background image
buildings.png - foreground image



    This project aims to provide a simple and customizable pull to refresh implementation.。

  • A UITableViewController subclass designed with efficiency and maintenance in mind, and tries its best to handle just about everything for you.

No more if-statements and switches in every table view dataSource and delegate method. No more splitting up all the logic for each row and section into a dozen different methods, making addition, removal, or minor alterations to format and layout a headache. We feel your pain, we know the struggle. Moving one section of cells below another, moving cells between sections, adding new cells to existing sections, etc., with a decently-complex table view can be a nightmare, but with Organic it's as simple as changing the order of objects in an array.

Organic allows you to define the sections and which cells they contain all-at-once, and takes care of the rest of the housekeeping for you.

Available via CocoaPods
pod ‘Organic’

See the example project for the detail usage.



    The intuitive UITableViewController。

  • Features
Change background color with shape animation
Perform transition animation between two views

Now there is only one interesting category UIView+MaterialDesign. Instance methods:

- (void)mdInflateAnimatedFromPoint:(CGPoint)point backgroundColor:(UIColor *)backgroundColor duration:(NSTimeInterval)duration completion:(void (^)(void))block;
- (void)mdDeflateAnimatedToPoint:(CGPoint)point backgroundColor:(UIColor *)backgroundColor duration:(NSTimeInterval)duration completion:(void (^)(void))block;
These methods allow you to change background color of a view using shape animation from any point, for example - touch, UISwitch or UIControl center.

Example for UIControl:

- (void)buttonAction:(UIControl *)sender event:(UIEvent *)event {
    CGPoint position = [[[event allTouches] anyObject] locationInView:self.subview];
    [self.subview mdInflateAnimatedFromPoint:position backgroundColor:[self randomColor] duration:0.33 completion:nil];

Static methods:

+ (void)mdInflateTransitionFromView:(UIView *)fromView
                             toView:(UIView *)toView
                         completion:(void (^)(void))block;

+ (void)mdDeflateTransitionFromView:(UIView *)fromView
                             toView:(UIView *)toView
                         completion:(void (^)(void))block;
- (void)showDetailsAction:(UIButton *)sender event:(UIEvent *)event {
    CGPoint exactTouchPosition = [[[event allTouches] anyObject] locationInView:self.viewOne];
    [UIView mdInflateTransitionFromView:self.viewOne toView:self.viewTwo originalPoint:exactTouchPosition duration:0.7 completion:nil];

These methods perform transition like UIView method:
[UIView transitionFromView:fromView toView:toView duration:duration options:UIViewAnimationOptionBeginFromCurrentState completion:nil];
but with shape animation from given point.

You could use this functinoality with any UIView instance without subclassing, cool, isnt'it? Source code is simple, customize, use, add merge requests!



    Inspired by Material Design guideline from Google.。

  • Setup

To use this control, we strongly recommend using CocoaPods. To do so add the following to your Podfile:

pod 'HUMSlider', ~>'1.0'
and then pod install.


A quick programmatic example of the most common use case:

    HUMSlider *slider = [[HUMSlider alloc] init];

    // Set the images to be saturated and desaturated
    slider.minimumValueImage = [UIImage imageNamed:@"minImage"];
    slider.maximumValueImage = [UIImage imageNamed:@"maxImage"];

    // What color should the image be when the thumb is close to it?
    slider.saturatedColor = [UIColor greenColor];

    // What color should the image be when the thumb is not close to it?
    slider.desaturatedColor = [[UIColor redColor] colorWithAlpha:0.5f]; 

    // How many ticks do you want?
    slider.sectionCount = 11; // This should be an odd number.

    // What color should the ticks be?
    slider.tickColor = [UIColor blackColor];    
Full code is available in the sample app included in this repo.



    A slider control with auto-appearing ticks and saturating images at each end. Straight from the codebase of Hum。

  • To use SYNFadingLabel, create a view in storyboard and set its class to SYNFadingLabel.

After creating an outlet, configure it like so:

self.fadingLabel.backgroundColor = [UIColor clearColor];
[self.fadingLabel configureWithFont:[UIFont fontWithName:@"AvenirNext-Regular" 
To make the label appear, just set its text:

[self.fadingLabel setText:@"page %@ / %@", curPage, totalPages];
The label will automatically fade away after the set delay.


SYNFadingLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SYNFadingLabel"



    A simple label with UIVisualEffectView vibrancy that automatically fades away.。

  • Installation

RKColorSlider is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "RKColorSlider"

- (IBAction)sliderDidChangeValue:(RKColorSlider *)sender
    self.testView.backgroundColor = sender.selectedColor;



    A color picker similar to the color picker found in Facebook Slingshot。

  • BreakOutToRefresh uses SpriteKit to add a playable mini game to the pull to refresh view in a table view. In this case the mini game is BreakOut but a lot of other mini games could be presented in this space.

Swift 1.2

The code is updated for Swift 1.2. If you like to use it with Xcode 6.1.1 and Swift 1.1 checkout the tag Swift1_1.


Add BreakOutToRefreshView.swift to your project.


Add this to your table view controller:

var refreshView: BreakOutToRefreshView!

  override func viewDidLoad() {

    let refreshHeight = CGFloat(100)
    refreshView = BreakOutToRefreshView(scrollView: tableView)
    refreshView.delegate = self

    // configure the colors of the refresh view
    refreshView.scenebackgroundColor = UIColor(hue: 0.68, saturation: 0.9, brightness: 0.3, alpha: 1.0)
    refreshView.paddleColor = UIColor.lightGrayColor()
    refreshView.ballColor = UIColor.whiteColor()
    refreshView.blockColors = [UIColor(hue: 0.17, saturation: 0.9, brightness: 1.0, alpha: 1.0), UIColor(hue: 0.17, saturation: 0.7, brightness: 1.0, alpha: 1.0), UIColor(hue: 0.17, saturation: 0.5, brightness: 1.0, alpha: 1.0)]



extension DemoTableViewController: UIScrollViewDelegate {

  override func scrollViewDidScroll(scrollView: UIScrollView) {

  override func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
    refreshView.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)

  override func scrollViewWillBeginDragging(scrollView: UIScrollView) {

extension DemoTableViewController: BreakOutToRefreshDelegate {

  func refreshViewDidRefresh(refreshView: BreakOutToRefreshView) {
    // load stuff from the internet

When the loading of new content is finished, call endRefreshing() of the refreshView.

When endRefreshing() is called the mini game doesn't stop immediately. The game stops (and the view is dismissed) when the user lifts the finger. If you like to end the mini game immediately set the forceEnd property to true.



    Play BreakOut while loading - A playable pull to refresh view using SpriteKit。

  • NKJPagerViewController is like a PagerTabStrip, which is in Android. It contains an endlessly scrollable UIScrollView.

pod "NKJPagerViewController"
Implement as subclass of NKJPagerViewController and imprement dataSource and delegate methods in the subclass.
- (void)viewDidLoad
    self.dataSource = self;
    self.delegate = self;
    [super viewDidLoad];

Decide number of tabs.
- (NSUInteger)numberOfTabView
    return 10;

Decide width for each tab.
- (NSInteger)widthOfTabView
    return 160;

Setting a view design for each tab.
- (UIView *)viewPager:(NKJPagerViewController *)viewPager viewForTabAtIndex:(NSUInteger)index
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
    label.backgroundColor = [UIColor grayColor];
    label.font = [UIFont systemFontOfSize:12.0];
    label.text = [NSString stringWithFormat:@"Tab #%lu", index * 10];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor blackColor];

    return label;

Setting a view controller for each tab.
- (UIViewController *)viewPager:(NKJPagerViewController *)viewPager contentViewControllerForTabAtIndex:(NSUInteger)index
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    ContentViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ContentViewController"];
    vc.textLabel = [NSString stringWithFormat:@"Content View #%lu", index];
    return vc;

- (void)viewPager:(NKJPagerViewController *)viewPager didSwitchAtIndex:(NSInteger)index withTabs:(NSArray *)tabs
    // do something



    NKJPagerViewController is like a PagerTabStrip, which is in Android. It contains an endlessly scrollable UIScrollView.。

  • This is an UICollectionView layout inspired by the photo section of facebook. This layout loads squared items with randomic full size items. It works with standard layout delegate methods. No additional custom methods to be implemented.


You can use this layout in your project by adding to your podfile:

pod 'FBLikeLayout'

Just allocate a new FBLikeLayout, then customize the few properties this layout comes with

FBLikeLayout *layout = [FBLikeLayout new];

//in this case we want 3 cells per row, maximum. This is also the default value if you do not customize the layout.singleCellWidth property 
CGFLoat cellWidth = (MIN(self.collectionView.bounds.size.width, self.collectionView.bounds.size.height)-self.collectionView.contentInset.left-self.collectionView.contentInset.right-8)/3.0;

layout.minimumInteritemSpacing = 4;
layout.singleCellWidth = cellWidth;
layout.maxCellSpace = 3; //for full size cells, this parameter determines the max cell space

//if you want the items size to be forced in order to have the minimumInteritemSpacing always respected. Otherwise the interitem spacing will be adapted in order to cover the complete row with cells
layout.forceCellWidthForMinimumInteritemSpacing = YES;
layout.fullImagePercentageOfOccurrency = 25; //this percent value determines how many times randomly the item will be full size.

self.collectionView.collectionViewLayout = layout;
Then just implement the UICollectionViewDelegateFlowLayout method:

-(CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath



    an UICollectionView layout inspired by the photo section of facebook。

  • IQAudioRecorderController is a drop-in universal library allows to record audio within the app with a nice User Interface. The Audio Recorder produced the .m4a file and returns the path via it's delegate methods.



    A neat and clean audio recorder.。

  • HSDatePickerViewController is an iOS ViewController for date and time picking, based on awesome look&feel; of Dropbox Mailbox application with some customization options.

Add sources from HSDatePickerViewControllerDemo/HSDatePickerViewController subfolder to your project.

Import main header:

#import "HSDatePickerViewController.h"
When needed, create HSDatePickerViewController object:

HSDatePickerViewController *hsdpvc = [HSDatePickerViewController new];
present it as modal view controller:

[self presentViewController:hsdpvc animated:YES completion:nil];
To get returning values, you must conform to the protocol HSDatePickerViewControllerDelegate:

@protocol HSDatePickerViewControllerDelegate <NSObject>
- (void)hsDatePickerPickedDate:(NSDate *)date;
- (void)hsDatePickerWillDismissWithQuitMethod:(HSDatePickerQuitMethod)method;
- (void)hsDatePickerDidDismissWithQuitMethod:(HSDatePickerQuitMethod)method;
Also, before presenting HSDatePickerViewController, you can change default values of some properties (check HSDatePickerViewController.h file for longer description):

@property (nonatomic, assign, getter=shouldDismissOnCancelTouch) BOOL dismissOnCancelTouch;

@property (nonatomic, assign) HSDatePickerMinutesStep minuteStep;

@property (nonatomic, strong) UIColor *mainColor;

@property (nonatomic, strong) NSDate *date;
@property (nonatomic, strong) NSDate *minDate;
@property (nonatomic, strong) NSDate *maxDate;

@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, strong) NSDateFormatter *monthAndYearLabelDateFormater;

@property (nonatomic, strong) NSString *confirmButtonTitle;
@property (nonatomic, strong) NSString *backButtonTitle;



    Customizable iOS view controller in Mailbox app style for picking date and time。

  • Installation

Just copy LSButton.h,LSButton.m into your project.


With storyboard
Chnage the UIButton class to LSButton.
And set the image.

With code
There has a quick way to make a LSButton.

+ (LSButton *)buttonWithFrame:(CGRect)frame
Change image color
LSButton always tint your image with tint color. So change the tint color.

Update button
If you change properties after drawRect:
You need call setNeedDisplay to update the view.



    Long shadow button for iOS。

  • With CoreTextLabel you are able draw NSAttributedString or HTML with custom font and color in iOS (>= 5.0) applications. numberOfLines and truncation (NSLineBreakByTruncatingTail) is also supported.


    CoreTextLabel * label  = [[CoreTextLabel alloc] initWithFrame:frame];
    label.html             = htmlString;
    [label sizeToFit];
    [self.view addSubview:label];


Add CoreTextLabel pod to your Podfile.

$ vim Podfile
platform :ios, '5.0'
pod 'CoreTextLabel', :head

Framework dependencies




    With CoreTextLabel you are able draw NSAttributedString or HTML with custom font and color in iOS (>= 5.0) applications.。

  • Manual

Drag the TAOverlay/TAOverlay folder into your project.
Ensure that TAOverlay.bundle is added to Targets->Build Phases->Copy Bundle Resources.
import "TAOverlay.h"


Showing TAOverlay

You can show the TAOverlay using one of the following:

+ (void) showOverlayWithLabel:(NSString *)status Options:(TAOverlayOptions)options;
The status parameter is the text to display on the overlay. If the value is 'nil', overlay is shown without a label
The options parameter is mask of options indicating the type and appearence of the overlay
+ (void) showOverlayWithLabel:(NSString *)status Image:(UIImage *)image Options:(TAOverlayOptions)options;
The status parameter is the text to display on the overlay. If the value is 'nil', overlay is shown without a label
The image parameter is the image to display as an icon on the overlay. The image cannot be 'nil'
The options parameter is mask of options indicating the appearence of the overlay
+ (void) showOverlayWithLabel:(NSString *)status ImageArray:(NSArray *)imageArray Duration:(CGFloat)duration Options:(TAOverlayOptions)options;
The status parameter is the text that you want displayed
The imageArray parameter is an array containing UIImage objects. Use this if your animation is easily expressable in images. The array cannot be 'nil'
The duration parameter is the duration of the animation to cycle through the array of images
The options parameter is mask of options indicating the appearence of the overlay
Dismissing TAOverlay

You can hide the TAOverlay using:

+ (void) hideOverlay;


[TAOverlay showOverlayWithLabel:@"This is the status" Options:(TAOverlayOptionOverlayTypeActivityDefault | TAOverlayOptionAllowUserInteraction | TAOverlayOptionOverlaySizeFullScreen | TAOverlayOptionAutoHide)];
The above shows the TAOverlay with the following properties:

-It's status is "This is a status"
-It's type is the default iOS Activity Indicator
-It's size is fullscreen
-It has user interaction enabled
-It has auto hide enabled



    TAOverlay is a minimalistic and simple overlay meant to display useful information to the user.。

Popular Code

More >
  • 左右菜单例子,类似于Facebook的ViewControllerContainer,在一个UIViewController上面加载另外一个UIViewController。点击主视图的导航条左右两边按钮,就会从左右两边分别滑动出子视图。

    left and right side menu


    Stack view demo, which mimics facebook's side bar menu。

  • 利用 Cocos2d-x 仿FlappyBird的Demo。
小编注:失败之后似乎不能重新开始。感谢开发者@ Alfred_Kruger 发布代码于。

    FlappyBird Demo


    A flappybird demo。

  • 实现循环ScrollView。有以下特色:
小编注:感谢开发者@遇见1986 分享代码于Code4App。

    circularly scrolling view


    A circularly scrolling view, which can load the image Asynchronously。

  • 自定义列表样式,包括在列表上加入多个控件,自定义列表的cell,header和footer。

    Custom Tableviews


    Custom UITableView's cell,header and footer。

  • 利用 cocos2d 制作切水果游戏。
小编注:这是raywenderlich cocos2d系列教程其中的一个Demo。结合代码看完教程,小编相信你会对cocos2d(特别是Box2D)有充分的了解。教程分成三部分,分别是:

    Fruit Ninja


    Fruit Ninja game made by cocos2d。

  • 实现可以自动旋转或者手动旋转的3D球形标签,点击标签会放大该标签。
小编注:感谢开发者@灵异幻影 发布代码于。

    3D Sphere View


    Tag cloud with 3D sphere layout, support scroll and touch actio。

  • 实现转盘菜单效果。转盘菜单用在建设银行的app中,点击转盘菜单上某个按钮,则菜单进行转动,被点击的按钮会慢慢被转到最前面。由于转动的过程中,按钮会有大变小或者由小变大,所以这个动画有3D的效果。

    Dial Menu


    A dial menu demo. Can scroll the screen to select different menu item。