Recently Added iOS Source Code Examples

More >
  • iOS custom view that let you add token view inside like NSTokenField.
Installation

pod 'ZFTokenField'

Usage

ZFTokenFieldDataSource

You need to implement these in your datasource class

lineHeightForTokenInField:tokenField: return desire line height.
numberOfTokenInField: return number of token that you want to display.
tokenField:viewForTokenAtIndex: return view that you want to display at specify index
ZFTokenFieldDelegate

tokenMarginInTokenInField: your prefered margin, default is 0
tokenField:didRemoveTokenAtIndex: get called when user deletes token at particular index.
tokenField:didReturnWithText: get called when user hits return with text.
tokenField:didTextChanged: get called when user changes text.
tokenFieldDidBeginEditing: get called when user begins edit the field.
tokenFieldShouldEndEditing: get called to ask if the field should end editing.
tokenFieldDidEndEditing: get called when user stops edit the field.

    ZFTokenField

    12/18/2014

    iOS custom view that let you add token view inside like NSTokenField。

  • A password strength view that uses smiley faces to depict the strength of a password.

-Set a custom font colour for the smiley faces, so that you can style it according to your app.
-Set a custom font size

Usage:
- (void)viewDidLoad {
    [super viewDidLoad];

    //Create the password strength view
    CGRect frame = CGRectMake(0, 0, CGRectGetHeight(self.passwordTextField.frame), CGRectGetHeight(self.passwordTextField.frame));
    self.smileyStrength = [[KMMSmileyStrength alloc] initWithFrame:frame];
    //Set it as the text field's right view
    self.passwordTextField.rightView = self.smileyStrength;
    self.passwordTextField.rightViewMode = UITextFieldViewModeNever;
}
/**
 *  Called when the text field's editing changed
 *
 *  @param sender the UITextField for the password
 */
-(IBAction)textDidChange:(id)sender {
    UITextField *textfield = sender;
    if(textfield.text.length > 0) {
        [self.smileyStrength evaluatePassword:textfield.text];
        self.passwordTextField.rightViewMode = UITextFieldViewModeAlways;
    } else {
        self.passwordTextField.rightViewMode = UITextFieldViewModeNever;
    }
}

    KMMSmileyStrength

    12/18/2014

    A password strength display using smiley faces。

  • The QRCodeReaderViewController is a simple QRCode Reader/Scanner based on the AVFoundation framework from Apple. It aims to replace ZXing or ZBar for iOS 7 and over.

It also allows you to switch between the front and the back cameras.

Manually
Download the project and copy the QRCodeReaderViewController folder into your project and then simply #import "QRCodeReaderViewController.h" in the file(s) you would like to use it in.

Usage
- (IBAction)scanAction:(id)sender
{
  QRCodeReaderViewController *reader = [QRCodeReaderViewController new];
  reader.modalPresentationStyle      = UIModalPresentationFormSheet;

  // Using delegate methods
  reader.delegate                    = self;

  // Or by using blocks
  [reader setCompletionWithBlock:^(NSString *resultAsString) {
    [self dismissViewControllerAnimated:YES completion:^{
      NSLog(@"%@", result);
    }];
  }];

  [self presentViewController:reader animated:YES completion:NULL];
}

#pragma mark - QRCodeReader Delegate Methods

- (void)reader:(QRCodeReaderViewController *)reader didScanResult:(NSString *)result
{
  [self dismissViewControllerAnimated:YES completion:^{
    NSLog(@"%@", result);
  }];
}

- (void)readerDidCancel:(QRCodeReaderViewController *)reader
{
  [self dismissViewControllerAnimated:YES completion:NULL];
}

    QRCodeReaderViewController

    12/18/2014

    Simple QRCode reader for iOS 7 and over。

  • This layout is an alternative to UICollectionViewFlowLayout that positions and sizes items using a defined number of columns and an aspect ratio property which force the size of cells, rather than the cells' size telling the layout how to position them (in the way UICollectionViewFlowLayout behaves). By default, this will always show the same number of items in a row no matter how large or small the collection view is.

You can specify the number of items per line and the desired aspect ratio of all items (which is always width / height, regardless of scroll direction):

layout.numberOfItemsPerLine = 5;
layout.aspectRatio = 16.0/9.0;
You can specify metrics similar to UICollectionViewFlowLayout, like so:

layout.sectionInset = UIEdgeInsetsMake(10,20,30,40);
layout.interitemSpacing = 15;
layout.lineSpacing = 5;
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
As of 0.1.x, this layout supports multiple sections, but no supplementary views and no per-section grid metrics.

Installation
KRLCollectionViewGridLayout is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "KRLCollectionViewGridLayout"

Usage
To run the example project, clone the repo, and run pod install from the Example directory first. You can either run unit tests on the library itself, or run the sample project for a visual demonstration.

    KRLCollectionViewGridLayout

    12/18/2014

    A UICollectionViewLayout that specifies item size and location by number of columns.。

  • Emulating the Imgur activity Indicator from the web.

Usage:
IMGActivityIndicator *indicator = [[IMGActivityIndicator alloc] initWithFrame:CGRectMake(screenWidth/ 2 - 50, screenHeight/2 - 50, 100, 100)];
    [self.view addSubview:indicator];

    IMGActivityIndicator

    12/15/2014

    Emulating the Imgur activity Indicator from the web。

  • Install
Just drag the folder named MHHexColoring to your project and add #import "UIColor+HexString.h"

to your header

usage
whenever you want to convert a hex color from your photoshop into UIColor .. just call

[UIColor colorWithHexString:@"#ffffff"];

Get Hex ColorCode:http://www.color-hex.com/

    MHHexColoring

    12/15/2014

    iOS Category to turn color hex string RBG to UIColor。

  • Custom alert view with gesture support and block-based API.

Usage

Wherever you want to use GUAAlertView, import the header file as follows:

#import "GUAAlertView.h"
Sample:

GUAAlertView *v = [GUAAlertView alertViewWithTitle:@"title"
                                           message:@"message"
                                       buttonTitle:@"buttonTitle"
                               buttonTouchedAction:^{
                                       NSLog(@"button touched");
                                   } dismissAction:^{
                                       NSLog(@"dismiss");
                                   }];

[v show];

    GUAAlertView

    12/15/2014

    Custom alert view with gesture support and block-based API。

  • Integration

DBPrivacyHelper is a simple UIViewController category and it has a simple integration:

Import UIViewController+DBPrivacyHelper.h
Open the modal using a simple method:
- (void) openHelper {
    [self showPrivacyHelperForType:DBPrivacyTypeLocation];
}
Use the other method to customize the controller or the action blocks:
- (void) openHelperToCustomize {
    [self showPrivacyHelperForType:DBPrivacyTypeLocation controller:^(DBPrivateHelperController *vc) {
        //customize the view controller to present
    } didPresent:^{
        //customize the completion block of presentViewController:animated:completion:
    } didDismiss:^{
        //customize the completion block of dismissViewControllerAnimated:completion:
    } useDefaultSettingPane:YES];
}
If useDefaultSettingPane: is set to YES, DBPrivacyHelper opens the default setting pane in iOS 8. Set NO if you want to see the DBPrivateHelperController with all iOS.
Privacy settings types:
-DBPrivacyTypePhoto
-DBPrivacyTypeCamera
-DBPrivacyTypeLocation
-DBPrivacyTypeHealth
-DBPrivacyTypeHomeKit
-DBPrivacyTypeMotionActivity

    DBPrivacyHelper

    12/15/2014

    Quick tool to explain the right place to enable your privacy settings。

  • MMScrollPresenter is a control for iOS development that takes an array of MMScrollPages and displays them in your UIScrollView.

I was initially insipired by a control in the Destiny App, so I'd recommend checking that out as well.

Example Usage

Download the repo and include MMScrollPresenter.h/.m, MMScrollPage.h/.m, arrow/@2x.png in your app
Drag and drop a UIScrollView into your Interface Builder and under the custom class section, subclass your UIScrollView to MMScrollPresenter
Now add: @property (weak, nonatomic) IBOutlet MMScrollPresenter *mmScrollPresenter; to your list of properties and dont forget to link it up in your Interface Builder
Add a MMScrollPage to the MMScrollPresenter
Here is a code snippet from the example app in the - (void)viewDidLoad method for #4:

UIImageView *mountainImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mountains.jpg"]];
[mountainImage setFrame:CGRectMake(0, 0, self.mmScrollPresenter.frame.size.width, self.mmScrollPresenter.frame.size.height)];

MMScrollPage *firstPage = [[MMScrollPage alloc] init];
firstPage.titleLabel.text = @"Look a picture of mountains";
firstPage.detailLabel.text = @"I'm the detail text";
[firstPage.backgroundView addSubview:mountainImage];
firstPage.titleBackgroundColor = [UIColor colorWithRed:119/255.0f green:92/255.0f blue:166/255.0f alpha:0.5];

[self.mmScrollPresenter setupViewsWithArray:@[firstPage]];

    MMScrollPresenter

    12/15/2014

    Custom UIScrollView Control for paging UIViews。

  • A replacement for ABPeoplePickerNavigationController that supports UILocalized​Indexed​Collation. ZLPeoplePickerViewController was originally created for Talkly.

Features

-Supports multilingual indexing and sorting by implementing UILocalized​Indexed​Collation using LRIndexedCollationWithSearch.
-Supports searching by name, emails and addresses. The results are displayed using UISearchController in iOS 8.
-Supports multiple selection.
-Supports field mask for filtering contacts.
-Support searching by phone number

More detail On gitHub or Demo.

    ZLPeoplePickerViewController

    12/12/2014

    A replacement for ABPeoplePickerNavigationController that supports UILocalized​Indexed​Collation。

  • UIUserNotificationSettings-Extension provides helper methods that will make you much easier to handle the new #iOS8 #Interactive #Notifications.

    UIUserNotificationSettings-Extension

    12/12/2014

    UIUserNotificationSettings-Extension provides helper methods that will make you much easier to handle the new #iOS8 #Interactive #Notifications.。

  • Features

-Dropdown view with blur+transform3D effect.
-Using keyframe animation from Core Animation.
-You can easily change the menu content view.

Installation

Drag the LMDropdownView folder into your project.
Add #include "LMDropdownView.h" to the top of classes that will use it.
Usage

You can easily integrate the LMDropdownView with a few lines of code. For an example usage look at the code below.

LMDropdownView *dropdownView = [[LMDropdownView alloc] init];
dropdownView.menuContentView = self.menuTableView;
[dropdownView showInView:self.view withFrame:self.view.bounds];
See sample Xcode project in LMDropdownViewDemo.

    LMDropdownView

    12/11/2014

    LMDropdownView is a simple dropdown view inspired by Tappy。

  • JTImageLabel is a simple view which contain a UILabel and a UIImageView which stay side by side, even if you change the alignment of the UILabel.

With CocoaPods, add this line to your Podfile.
pod 'JTImageLabel', '~> 1.0'

It's very easy to use.

#import <UIKit/UIKit.h>
#import "JTImageLabel.h"
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet JTImageLabel *label;
@end
You can access directly to the imageView and the textLabel. Also you can define the space between the two views.

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.label.imageView.image = [UIImage imageNamed:@"icon"];
    self.label.textLabel.text = @"Test";
    self.label.textLabel.textAlignment = NSTextAlignmentRight;
    self.label.space = 10.; // Add a space between the imageView and the textLabel
}

You cannot change the frame of the imageView and the textLabel. The imageView has the same size as this image and the textLabel adapts to its relative content.

    JTImageLabel

    12/10/2014

    JTImageLabel keeps a UILabel and a UIImageView side by side。

  • Custom UICollectionViewLayout that works together with a custom UICollectionViewCell to provide drag and drop for a UICollectionView. Works just like UITableView drag and drop. What's unique about this approach is that it does not need to create a "ghost" or "dummy" cell to provide the drag and drop functionality. I believe this method is simpler and less complex for the majority of use cases.

Adding to your project:
Cocoapods

CocoaPods is the recommended way to add HTKDragAndDropCollectionViewLayout to your project.

Add a pod entry for HTKDragAndDropCollectionViewLayout to your Podfile pod 'HTKDragAndDropCollectionViewLayout', '~> 0.0.1'
Install the pod(s) by running pod install.
Subclass HTKDragAndDropCollectionViewController.
Setup HTKDragAndDropCollectionViewLayout properties (itemSize, lineSpacing, etc).
Subclass and use HTKDraggableCollectionViewCell which implements the gestures for dragging.
Implement - (void)userDidEndDraggingCell:(UICollectionViewCell *)cell and if the HTKDragAndDropCollectionViewLayout finalIndexPath is not nil, insert the draggedIndexPath into the finalIndexPath's position. See example in project.

    HTKDragAndDropCollectionViewLayout

    12/10/2014

    UICollectionViewLayout subclass that works together with a custom UICollectionViewCell to provide drag and drop for a UICollectionView。

  • UIImageView subclass that loads the image progressively.

Usage:
#import "MDIncrementalImageView.h"

MDIncrementalImageView *imageView = [[MDIncrementalImageView alloc] initWithFrame:CGRectMake(25, 5, 100, 100)];
[imageView setImageUrl:[NSURL URLWithString:[dataSource objectAtIndex:indexPath.row]]];

More detail in demo.

    MDIncrementalImageView

    12/10/2014

    UIImageView subclass that loads the image progressively。

  • CountryPicker is a custom UIPickerView subclass that provides an iOS control allowing a user to select a country from a list. It can optionally display a flag next to each country name, and the library includes a set of 249 public domain flag images from https://github.com/koppi/iso-country-flags-svg-collection that have been renamed to work with the library.

Note that the list of countries is based on the ISO 3166 country code standard (http://en.wikipedia.org/wiki/ISO_3166-1). This list excludes certain smaller countries, regarding them as part of a larger state. For example, England, Scotland, Wales and Northern Ireland are lumped together as Great Britain. For most purposes this is fine as it matches the convention used for locales, but if you need to specify additional countries, you can subclass and modify the countires list as described under "Subclassing" below.

    CountryPicker

    12/08/2014

    CountryPicker is a custom UIPickerView subclass that provides an iOS control allowing a user to select a country from a list。

  • Complete iOS camera engine with Vine like pause/resume, filters, ghost mode, player with smooth loop, exporter with precise parameters

A Vine/Instagram like audio/video recorder and filter framework in Objective-C.

In short, here is a short list of the cool things you can do:

Record multiple video segments
Remove any record segment that you don't want
Display the result into a convenient video player
Save the record session for later somewhere using a serializable NSDictionary (works in NSUserDefaults)
Add a video filter using Core Image
Merge and export the video using fine tunings that you choose
Examples for iOS are provided.

Framework needed:

CoreVideo
AudioToolbox
GLKit

More Detail in Demo or See the usage in Github.

    SCRecorder

    12/08/2014

    A Vine/Instagram like audio/video recorder and filter framework in Objective-C。

  • Advantages

-Can be full screen
-Uses UIMotionEffect
-Animates text update
-Animates succes checkmark
-Is well documented
-Is fully customizable
-Colors
-Fonts
-Circle size and thickness

More Usage and Detail In Demo.

    KVNProgress

    12/08/2014

    KVNProgress。

Popular Code

More >
  • 简单实现视频的边下载边播放功能。
原理是这样的:
在iOS本地开启Local Server服务,然后 MPMoviePlayerController 请求本地Local Server服务。本地Local Server服务再不停的去对应的视频地址获取视频流。本地Local Server请求的时候,就可以把视频流缓存在本地。
作者说:网上看到的教程没有相对应的demo。就写一个希望对初学者有所帮助。大鸟勿喷。
@小编注:感谢开发者@K说K话 发布代码于Code4App.com。

    Download and play video

    3479 downloads

    Support play the video while downloading the video。

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

    ZXing Demo

    2258 downloads

    使用ZXing库实现二维码扫描、自定义扫描控件及二维码生成。

  • 实现类似QQ的聊天功能界面,利用气泡(bubble)视图显示对话消息,可以同时输入文字和表情。

    Styled Chat

    1805 downloads

    The StyledChatDemo is a chat bubble demonstration project inspired by the open source Adium.The demo adapted the Adium's Renkoo message style,supported dynamically changing the style variant。

  • OpenEars是一个开源的iOS类库,用于在iPhone和iPad实现语音识别功能。本demo利用此开源类库实现了简单的语音识别。可以识别:CHANGE、LEFT、RIGHT、FORWARD、BACKWARD、GO等英文,其他语素需要训练。
小编注:只能在真机中测试。打开demo后,点击开始按钮,然后对着手机说以上几个英文单词。注意发音要大声、清晰、准确一点,才能够识别。比如说“Change”,笑脸会变成哭脸,说“Left”,笑脸会移到右边(是的,是右边,是bug吗?)

    speech recognition

    1780 downloads

    Use OpenEars library to implement speech recognition。

  • 实现饼状的菜单。菜单上的按钮呈现饼状排列,用户用手指滑动选择。这种菜单常见于播放器应用。

    Pie Menu

    1733 downloads

    A pie menu implementation specially designed for iPhone and iPod touch。

  • 自定义 UIAlertView 的样式,包括背景颜色、边框等等,更重要的是,能够自定义 Alert View 的弹出和消失的动画,包括渐隐渐现、翻转、坠落等等。

    URBAlertView

    1624 downloads

    A completely custom UIAlertView that supports custom drawing for the core component and internal buttons。

  • 在地图上覆盖透明的圆形区域,圆形区域的中心点、直径和颜色都可以自定义。除外,这份代码能很容易嵌入程序,用于关于位置的功能实现,比如定位等等。

    Location Manager

    1595 downloads

    Easy Location Manager Framework。