Recently Added iOS Source Code Examples

More >
  • ViewController to describe the User how to turn on the Notifications

NSString *title = @"Benachrichtungen aktivieren";
NSString *descriptionString = @"Um die Notificationen verwenden zu können müssen sie die Banachrichtungen aktivieren.";

MHNotificationHelperObject *notificationObject = [MHNotificationHelperObject objectWithTitle:title
                                                                                     appName:@"meine App"];

MHNotificationHelperViewController *notificationHelper = [MHNotificationHelperViewController.alloc initWithNotification:notificationObject];
notificationHelper.bannerLabel.text = NSLocalizedString(@"Banner", nil);

[self presentViewController:notificationHelper animated:YES completion:nil];



    ViewController to describe the User how to turn on the Notifications。

  • Drop the MAThemeKit.h/m files into your project, import the header into your AppDelegate.m file, and in the application:didFinishLaunchingWithOptions: method tell MAThemeKit what you'd like your primary and secondary theme colors to be, what you want for a font for your applications Navigation/TabBar's and if you'd like the status bar to be light or not. (NOTE - you'll still need to manually add the 'View controller-based status bar appearance' key to your Info.plist and set it to NO for the status bar to be set to light content.)



    MAThemeKit provides iOS developers the ability to create a coherent color theme throughout their entire application using a single line of code, removing the need to mess with the dozens of UIAppearance proxies for each UI component.。

  • IQMediaPickerController contains 3 library IQMediaCaptureController, IQAssetsPickerController & IQAudioPickerController. All libraries are separate from the others, so if you want to integrate any one of them, you can copy only required library without copying others.



    IQMediaPickerController allows user to capture Videos, Images and Audio using AVFoundation framework。

  • AMPActivityIndicator is a custom UIView subclass that mimics the UIActivityIndicatorView behavior.

You can customize:
The color
The width of each bar
The height of each bar
The aperture (distanfe from the center)



    AMPActivityIndicator is a custom UIView subclass that mimics the UIActivityIndicatorView behaviour。

  • AmazingButton *button = [[AmazingButton alloc] initWithFrame:CGRectMake(85, 100, 50, 50) color:[UIColor orangeColor]     type:AmaButtonTypeUser];



    AmazingButton is look like net ease news app button style.。

  • BKCardNumberField

// create (you can also use interface builder)
BKCardNumberField *cardNumberField = [[BKCardNumberField alloc] initWithFrame:CGRectMake(0, 0, 300, 40)];
cardNumberField.showsCardLogo = YES;
[self.view addSubview:cardNumberField];

// get card number
NSString *cardNumber = cardNumberField.cardNumber;

// get card company name
NSString *companyName = cardNumberField.cardCompanyName;

BKCardExpiryField *field = [[BKCardExpiryField alloc] init];

// get month
NSInteger month = field.dateComponents.month;

// get year
NSInteger year = field.dateComponents.year;

BKCurrencyTextField *field = [[BKCurrencyTextField alloc] init];

// change currency
field.numberFormatter.currencyCode = @"KRW";

// get number value
NSDecimalNumber *number = field.numberValue;



    BKMoneyKit iOS UI controls and formatters for entering money, credit card number and expiry date.。

  • JYGraphViewController is a slightly adapted version of the graph that appears in Tempo/Weather. It is meant to be presented modally and using the whole screen. The demo application it belongs to here presents it using an orientation change notification, but it could be triggered via any action. The benefit of having it presented based on orientation is that you don't have to obscure the graph with any controls. From a UX point of view, animating the presentation helps the user understand the graph is affected by gravity: ie. slides out when device is turned into landscape, and falls back away when returned to portrait.

- (void) didRotate
    if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft ||
        [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {

    JYGraphViewController *graphView = [[JYGraphViewController alloc] initWithNibName:@"JYGraphViewController" bundle:nil];

    // Set the data for the graph
    // Send only an array of number values
    graphView.graphData = [self createArrayOfNumbersToPassToGraph];

    // Set the xAxis labels (optional)
    // Can send numbers or strings (it's printed using stringWithFormat:"%@")
    graphView.graphXAxisLabels = [self createXAxisLabelArray];

    [self presentViewController:graphView animated:YES completion:nil];



    JYGraphViewController is an easy way to graph data in a simple and minimalist style. By default it is presented modally when the device is turned into landscape orientation。

  • IRImageTableView Class

@property (nonatomic, strong) NSArray *data;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, weak) id <IRImageTableViewDelegate> delegate;

-(id)initWithTable:(UITableView*)aTable withData:(NSArray *)aData;


IRImageTableViewDelegate Protocol

@protocol IRImageTableViewDelegate <NSObject>
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;



    A solution to add a UIImageView in an UITableView (inspired by Tweetbot)。

  • Here we should set the titles,finishedDownloadingButtonTitle, and buttonDelegate !!!.

MOStoreButton*storeButton1 =[[MOStoreButton alloc]initWithFrame:CGRectMake(100, 260,80, 40) andColor:[UIColor blueColor]];

storeButton1.titleLabel.font =[UIFont systemFontOfSize:17];
storeButton1.finishedDownloadingButtonTitle =@"Open";
[storeButton1 setTitles:@[@"free",@"INSTALL"]];
[self.view addSubview:storeButton1]; 


We Care here about the currentIndex which determine the state of the button transition, see the demo for more clarification

-(void)storeButtonFired:(MOStoreButton *)button{

NSLog(@"click  %i",button.currentIndex);




    simple-to-use iOS 7 Appstore like button。

  • Flat Rounded Style

    self.flatRoundedButton = [[VBFPopFlatButton alloc]initWithFrame:CGRectMake(100, 150, 30, 30)
self.flatRoundedButton.roundBackgroundColor = [UIColor whiteColor];
self.flatRoundedButton.lineThickness = 2;
self.flatRoundedButton.tintColor = [UIColor flatPeterRiverColor];
[self.flatRoundedButton addTarget:self
[self.view addSubview:self.flatRoundedButton];
Flat Plain Style

    self.flatPlainButton = [[VBFPopFlatButton alloc]initWithFrame:CGRectMake(200, 150, 30, 30)
self.flatPlainButton.lineThickness = 2;
self.flatPlainButton.tintColor = [UIColor whiteColor];
[self.flatPlainButton addTarget:self
[self.view addSubview:self.flatPlainButton];
In both cases, you can use the following method to animate the button from one state to the next:

[flatRoundedButton animateToType:nextType];
This are the 9 types avaiable for the button:

typedef NS_ENUM(NSInteger, FlatButtonType) {
buttonDefaultType,             // Vertical line
buttonAddType,                 // +
buttonMinusType,               // -
buttonCloseType,               // x
buttonBackType,                // <
buttonForwardType,             // >
buttonMenuType,                 // 3horizontal lines



    VBFPopFlatButton通过Facebook Pop实现按钮的动态变换。

  • Drop the OnboardingViewController and OnboardingContentViewController header and implementation files into your project, import them into your AppDelegate, and you're ready to create an awesome onboarding experience for your users!

Create individual pages by creating an OnboardingContentViewController, providing it a title, body, image, text for an action button, and within the action block handle whatever you want to do when the users press the button. If you don't want a button, you can leave both the button text and action handler nil.

OnboardingContentViewController *firstPage = [[OnboardingContentViewController alloc] initWithTitle:@"Page Title" body:@"Page body goes here." image:[UIImage imageNamed:@"icon"] buttonText:@"Text For Button" action:^{
    // do something here when users press the button, like ask for location services permissions, register for push notifications, connect to social media, or finish the onboarding process



    nboard provides developers with a quick and easy means to create a beautiful, engaging, and useful onboarding experience with only a few lines of code。

  • ARTEmailSwipe is a UIViewController container, which allows you to have one view controller at the bottom, whilst keeping your main navigation separate. This is based on the iOS 8 emails implementation where you can have your new email open at the bottom whilst still viewing all your old emails above it. I also took a lot of inspiration from the JASidePanels project.

Example 1: Code

#import "ARTEmailSwipe.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.viewController = [[ARTEmailSwipe alloc] init];

  // you will want to use your own custom classes here, but for the example I have just instantiated it with the UIViewController class.
    self.viewController.centerViewController = [[UIViewController alloc] init];
    self.viewController.bottomViewController = [[UIViewController alloc] init];

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;




    ARTEmailSwipe is a UIViewController container。

  • #import "JMAnimatedImageView.h"
#import "JMAnimatedImageView.h"

//GIF example
@property (weak, nonatomic) IBOutlet JMAnimatedImageView *jmImageView;

[self.jmImageView reloadAnimationImagesFromGifNamed:@"rock"];
self.jmImageView.animationType = JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutAnimation;
[self.jmImageView startAnimating];



    JMAnimatedImageView is a performant subclass of UIImageView。

  • A simple implementation of a reorderable UITableView. It relies on UILongPressGestureRecognizer, and only public APIs (it's street legal). Simpler than some of the other solutions I've seen out there.



    A quick implementation of a reorderable UITableView.。

  • func setVenueCollection(array: [Venue]!) {
         if (array != nil) {
            venues = array!



    Mimic Find My Friends first screen behavior。

  • LFHeatMap is a simple UIImage generator. The resulting object can be used like any other UIImage, standalone or in a UIImageView. While it can be overlaid on top of a MKMapView, it is not strongly tied to this specific component and hence does not offer the benefits that come with a more complex implementation of MKOverlayRenderer.

Adding LFHeatMap to Your Project


CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like LFHeatMap in your projects. See the "Getting Started" guide for more information.

platform :ios, '5.0'
pod "LFHeatMap"
Source Files

Alternatively you can directly add the LFHeatMap folder to your project.


This demo plots the measured magnitudes of the 2011 Virginia Earthquake.


Open and launch the LFHeatMapDemo XCode project.
Move the slider on the bottom to adjust the boost.

The data is stored in quake.plist which is a simple plist storing the latitude, longitude, and magnitude of each measurement. The points (locations) and weights (magnitudes) are stored in two NSArray objects in viewDidLoad of LFHeadMapDemoViewController.

The main action takes place in the sliderChanged: function. Moving the slider determines the new boost value and generates a new heat map image. The image's dimensions are the same as the self.mapView object, with the points and weights supplied by the two data arrays. The image is then passed to the overlaying UIImageView that sits on top of the map.


This class contains the three basic static functions used to generate the heat maps.

1. Basic Heat Map

Supply the desired image dimensions and boost, as well as the point/value arrays. There should be a 1:1 mapping between these two arrays, that is each index in the points array should have a corresponding index in the weights array.

rect: region frame
boost: heat boost value
points: array of NSValue CGPoint objects representing the data points
weights: array of NSNumber integer objects representing the weight of each point

UIImage object representing the heatmap for the specified region.

+ (UIImage *)heatMapWithRect:boost:points:weights:
2. Advanced Heat Map

Works generally the same as the basic heat map, but allows to tweak two additional parameters to control the "bleed" of heat rendering.

rect: region frame
boost: heat boost value
points: array of NSValue CGPoint objects representing the data points
weights: array of NSNumber integer objects representing the weight of each point
weightsAdjustmentEnabled: set YES for weight balancing and normalization
groupingEnabled: set YES for tighter visual grouping of dense areas

UIImage object representing the heat map for the specified region.

+ (UIImage *)heatMapWithRect:boost:points:weights:weightsAdjustmentEnabled:groupingEnabled:
3. MKMapView Helper

Works the same as the basic heat map, but allows you to supply map-specific parameters. Pass an MKMapView object (typically the target you want to overlay), and an array of CLLocation objects corresponding to coordinates on the specified MKMapView object.

The function will convert these to the required CGRect/CGPoint values as needed.

mapView: Map view representing the heat map area.
boost: heat boost value
locations: array of CLLocation objects representing the data points
weights: array of NSNumber integer objects representing the weight of each point

UIImage object representing the heatmap for the map region.

+ (UIImage *)heatMapForMapView:boost:locations:weights:



    LFHeatMap is a simple UIImage generator.。

  • Instead of showing a gray overlay before the user can start playing with your app (a common practice as of today), we thought it would be better to show these "tips" as needed according to the usage.

SALQuickTutorial supports showing a view with a title, an image and a message. By default, to close, the user just needs to tap the screen, but you can configure it to work with a dismiss button. Also, you can set a completion block to be called when the view is dismissed.

Here at Seeking Alpha we decided to shift, in our next iOS version, from the gray overlay to the quick tutorials when they are really needed.

We invite you to contribute with our first iOS open source project.



The extremely simple way

You can use the class method below, if you just want to show the quick tutorial without customizing too much:

[SALQuickTutorialViewController showIfNeededForKey:@"MyUniqueKey" title:@"This feature is awesome" message:@"It's the best feature ever developed in an iOS app" image:[UIImage imageNamed:@"myFeatureImage"]];
Calling this method will:

Verify if the user already saw this tutorial, according to the key you pass;
In case he didn't, will create the quick tutorial based on the title, message and image you pass. The default configurations are that dismiss is done by tapping anywhere, and no support for completion block when dismissed.
The simple way

Sometimes, you will want to disable the tap-anywhere-to-dismiss and add a Got it! button. Wow, SALQuickTutorial supports it! Or, maybe, you want your app to know when the user dismissed it.

    //first, verify if you have shown it already
    if ([SALQuickTutorialViewController needsToShowForKey:@"MyUniqueKey"]) {
        SALQuickTutorialViewController *quickTutorialViewController = [[SALQuickTutorialViewController alloc] initWithKey:@"MyUniqueKey" title:@"This feature is awesome" message:@"It's the best feature ever developed in an iOS app" image:[UIImage imageNamed:@"myFeatureImage"]];

        //if you want to enable dismiss only with the button:
        quickTutorialViewController.dismissesWithButton = YES;

        //if you want to set the completion block:
        [quickTutorialViewController setDidDismissCompletionHandler:^{
            [[[UIAlertView alloc] initWithTitle:@"SALQuickTutorialViewController supports completion block" message:[NSString stringWithFormat:@"Quick tutorial with key %@ was dismissed", @"MyUniqueKey"] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil] show];

        //just show it
        [quickTutorialViewController show];



    Show quick tutorials, only once, while the user discovers your app.。

  • NOTE: This is has not yet been thoroughly tested and is in alpha, I would strongly advise against using this in any release builds.

MALoggingViewController is a real-time pseudo-console you can embed in your application, perfect for testing and debugging in the real world. Whether you are determining the reliability of network traffic while driving through areas with poor service, testing push notifications on ad-hoc builds while not connected to Xcode, or working out those pesky Core Location bugs, there's no need to carry around half of your development environment with you. No more driving around town with the Xcode console open, or having to handle logging to files and emailing them later to figure out what the heck happened - you can see all the data on your device, anywhere, in real time.

This is not meant to be a replacement for something like CocoaLumberjack, and is absolutely not optimized for speed or efficiency, but for day-to-day testing and debugging this is a pretty neat tool.

Drop MALoggingViewController.h/m into your project, import the header into your AppDelegate.h, and create a MALoggingViewController property on your AppDelegate.

You can put your MALoggingViewController anywhere in your application, keep it somewhere super-secret hidden with a password, or rip it out entirely for all your production builds. When you're ready to start logging important information on screen, simply call logToView: and pass in an NSLog-type message with arguments and the result will be added to the MALoggingView as well as logged normally to the console. From anywhere else in your application, all you need to do is access the AppDelegate's MALoggingViewController property and tell it what and when to log.

MALoggingViewController *loggingVC = [MALoggingViewController new];
self.logger = loggingVC;
[self.logger logToView:@"Some message goes here with param1: %@, param2: %@", firstParam, secondParam];



    MALoggingViewController is a real-time pseudo-console you can embed in your application, perfect for testing and debugging in the real world. 。

Popular Code

More >
  • 一个使用ZXing库实现二维码扫描、自定义扫描控件及二维码生成的例子。项目中包含了ZXing自带扫描控件的使用,自定义扫描控件的界面,从相册中读取照片解析二维码,以及生成二维码的功能。解码使用ZXing库,编码使用QRCodeEncoder库。
小编注:感谢开发者@禁行线 分享代码于Code4App。

    ZXing Demo



  • 利用 cocos2d 模仿合金弹头的特种任务做的一个demo,包括几个场景,可以发射子弹、跳跃和前进。
作者说:在iphone真机retina显示屏上能运行重力感应控制方向,单指按攻击,双指按跳跃。还没开发完毕,遇到一些困难,希望有相关经验的的前辈指点或者发送一些类似游戏demo给 。
小编注:只能在真机retina显示屏上才能正确运行。感谢开发者@草庐软件 分享代码于Code4App。

    Metal Slug Demo


    Metal Slug demo made by cocos2d。

  • 利用cocos2d制作的一款类塔防游戏。游戏规则是本方城堡和敌方城堡互相开炮射击,可以修建城堡以及买大炮。有几个比较不错的实现,可以供开发者学习一下:炮弹射出的烟雾效果,堡垒被击中的坍塌效果,以及旋转屏幕的伪3D效果等等。

    Castle Hassle


    A physics-based cocos2d iOS game。

  • Pinch手势对图片进行缩放。即用两根手指往不同方向拖拉照片,照片会被缩小或放大。
小编注:感谢开发者@基调中国 分享代码于Code4App。

    scale an image by pinch


    Use pinch gesture to scale an image。

  • Bee Framework 是一款iOS平台的MVC应用快速开发框架。其早期原型曾经被应用在 QQ游戏大厅 for iPhone、QQ空间 for iPhone 等多款精品APP中。 Bee 从根本上解决了iOS开发者长期困扰的各种问题,诸如:分层架构如何设计,层与层之间消息传递与处理,网络操作及缓存,异步及多线程,以及适配产品多变的UI布局需求。
小编注:由于这份代码会不断更新,所以小编将下载地址直接链接到项目的github地址,保证大家下载到最新代码,以及阅读文档。感谢开发者@Hellonly5 推荐代码于Code4App。

    Bee Framework


    A Powerful rapid MVC framework for iOS。

  • 基于 cocos2d-x 编写的对对碰游戏。即三个相同图案排成一行的时候就会消去。
小编注:感谢开发者@埃博拉病毒 分享代码于Code4App。

    Puzzle game by cocos2d-x


    Puzzle game made by cocos2d-x。

  • 以Kal日历控件为基础,界面更新为IOS7扁平化风格。并且可以设置单选和范围选择两种模式。还可以设置初始选择日期和可选日期的范围。
小编注:感谢开发者@文祥 发布代码于。

    Kal for IOS 7


    A calendar component for the iPhone (the UI is designed to match MobileCal)。