Recently Added iOS Source Code Examples

More >
  • UIImage *image0 = [UIImage imageNamed:@"main-camera-button"];
UIImage *image1 = [UIImage imageNamed:@"main-library-button"];
NSArray *images = @[image0, image1];

    PicsLikeControl

    10/20/2014

    A kind of customized button (users can customize the function of the button with a simple fling)。

  • Circle shaped control to select given number of values.

Structure:

There are three kinds of objects:

NOCircleSelector, which is an UIView and represents the whole area where the control is drawn. MIN(selector.width, selector.height) / 2 is the radius of selector.
NOCircleDot, which is an UIView and represents the single dot. The size and all properties can be changed via properties. Don't forget about normal UIView properties. The control is easy to subclass so you can easily add custom views. To access it use delegate methods or dots array of NOCircleSelector.
NOCircleDotConnection - a model class, representing the line between two NOCircleDot. You can customise it via properties. To access it use delegate methods or dotConnections array of NOCircleSelector. The recommended method to differ the dot is to use NS_ENUM and set tags of these.
Customisable:

In NOCircleSelector (+ all UIView properties like backgroundColor etc):

numberOfDots
[_circleSelector setNumberOfDots:4];
dotRadius
[_circleSelector setDotRadius:50.f];
lineWidth - sets defaults in NOCircleDotConnection
[_circleSelector setLineWidth::2.f];
lineColor - sets defaults in NOCircleDotConnection
[_circleSelector setLineColor:[UIColor redColor]];
fillColor
[_circleSelector setFillColor:[UIColor blueColor]];
In NOCircleDot (+ all UIView properties like backgroundColor etc):

lineWidth
[dot setLineWidth:2.f];
lineColor
[dot setLineColor:[UIColor redColor]];
fillColor
[dot setFillColor:[UIColor greenColor]];
textLabel
[dot.textLabel setText@"Hello!"];
imageView
[dot.imageView setImage:[UIImage imageNamed:@"girl"]];
angle - degrees, represents current angle of dot in selector
[dot setAngle:90.f];
minAngle - degrees, represents non crossable minimum range of dot in selector. Default 0.
[dot setMinAngle:0.f];
maxAngle - degrees, represents non crossable maximum range of dot in selector. Default 360.
[dot setMaxAngle:360.f];
In NOCircleDotConnection:

startDot - set automatically, do not overload if not required. Describes the first dot of connection.
endDot - set automatically, do not overload if not required. Describes the second dot of connection.
connectionColor
[connection setConnectionColor:[UIColor redColor]];
lineWidth
[connection setLineWidth:3.f];
dotConnectionBeetweenTag1:tag2: - convenience method to compare whether 2 dots are connected.
[dot setLineWidth:2.f];

    NOCircleSelector

    10/20/2014

    Circle shaped control to select given number of values.。

  • NSMutableArray *dropdownItems = [[NSMutableArray alloc] init];
IGLDropDownItem *item = [[IGLDropDownItem alloc] init];
[item setIconImage:[UIImage imageNamed:@"icon.png"]];
[item setText:@"title"];
[dropdownItems addObject:item];

    IGLDropDownMenu

    10/20/2014

    An iOS drop down menu with pretty animation.。

  • MagnetPopupPicker
Simple and easy to use drop down substitution for IOS.

Usage:

self.button = [[PopupPickerButton alloc] initWithFrame:CGRectMake(11, 50, 150, 30)];

[self.button setTitle:@"Select" forState:UIControlStateNormal];

NSArray *list = [NSArray arrayWithObjects:[KeyValuePair keyValuePairWithKeyAndValue:@"test1" value:@"Test 1"], [KeyValuePair keyValuePairWithKeyAndValue:@"test2" value:@"Test 2"], [KeyValuePair keyValuePairWithKeyAndValue:@"test3" value:@"Test 3"], nil];

[self.button setOptions:list keyNames:[KeyValuePair keyValuePairWithKeyAndValue:@"key" value:@"value"]];

    MagnetPopupPicker

    10/20/2014

    Simple and easy to use drop down substitution for IOS.。

  • KINWebBrowser consists of a single component:

KINWebBrowserViewController - a UIViewController that contains a full featured web browser.

KINWebBrowserViewController must be contained in a UINavigationController.

Pushing to the navigation stack:

KINWebBrowserViewController *webBrowser = [KINWebBrowserViewController webBrowserViewController];
[self.navigationController pushViewController:webBrowser animated:YES];
[webBrowser loadURLString:@"http://www.example.com"];

    KINWebBrowser

    10/17/2014

    KINWebBrowser is a web browser module for your apps.。

  • this doesn't use AHEasing, instead it uses CAMediaTimingFunction. Created mainly because the previously mentioned repo doesn't support ios8 and results in spazzy animations and also has problems with 64bit architecture.

    UIView+Easing

    10/17/2014

    Inspired from UIView-EasingFunctions with some difference in implementation。

  •  JBSpacer calculates optimal spacing for a grid of items while maintaining a specified ratio between inner gutter and outer margin sizes

Requirements

JBSpacer has been built and tested for iOS 8, though it should work with iOS 6 and later. Also, while JBSpacer may work for Mac development with slight modification (for example, to accomodate NSCollectionView), I have not tried this myself.

Usage

Add JBSpacer.h/.m and JBSpacerOption.h/.m to your project. Then:

#import "JBSpacer.h"
To configure an option:

JBSpacerOption *option = [JBSpacerOption optionWithItemSize:50.0f
                                              minimumGutter:2.0f
                                        gutterToMarginRatio:1.0f
                                              availableSize:320.0f
                                   distributeExtraToMargins:YES]];
The spacer performs its calculations in a single dimension, assuming that the second dimension (for example, in a UICollectionView) will scroll. In this example, both the itemSize and availableSize parameters represent widths, though they could just as easily be used as heights in other layout scenarios.

The gutterToMarginRatio parameter is a factor that represents the acceptable margin size as it relates to the gutter size. In this example, the minimumGutter parameter is set to 2.0, so the minimum margin size would be 2.0 x 1.0 = 2.0. If the final gutter size was 3.5, the margin size would also be 3.5, and so on.

The distributeExtraToMargins parameter controls whether any extra space should be distributed into the margins. Not all calculations result in perfect solutions, and this is a way to hide the extra space while maintaining a pleasant balance. Because calculations are performed at the pixel (not point) level, there is typically very little extra space to account for, and it can easily hide in the margins without significantly impacting the gutterToMarginRatio.

To calculate spacing, create a JBSpacer with the specified option:

JBSpacer *spacer = [JBSpacer spacerWithOption:option];
The spacing property of the spacer contains the results of the calculation.

To consider multiple options, call findBestSpacingWithOptions:. This provides the spacer with more than one acceptable solution, and it will find the solution with the tightest presentation:

BOOL success = [spacer findBestSpacingWithOptions:
                @[[JBSpacerOption optionWithItemSize:78.5f
                                       minimumGutter:2.0f
                                 gutterToMarginRatio:0.0f
                                       availableSize:320.0f
                            distributeExtraToMargins:YES],
                  [JBSpacerOption optionWithItemSize:78.5f
                                       minimumGutter:2.0f
                                 gutterToMarginRatio:1.0f
                                       availableSize:320.0f
                            distributeExtraToMargins:YES]]];
To use the optimal spacing with a UICollectionView, apply the results to an instance of UICollectionViewFlowLayout:

[spacer applySpacingToCollectionViewFlowLayout:flowLayout];
And that's it. Enjoy!

    JBSpacer

    10/17/2014

    JBSpacer calculates optimal spacing for a grid of items while maintaining a specified ratio between inner gutter and outer margin sizes。

  • A view controller subclass that presents placeholder views based on content, loading, error or empty states.

Usage
Configure the loadingView, emptyView and errorView properties of your StatefulViewController subclass in viewDidLoad.

After that, simply tell the view controller if content is currently being loaded and it will take care of showing and hiding the correct loading, error and empty view for you.

func loadDeliciousWines() {
    startLoading()

    let url = NSURL(string: "http://example.com/api")
    let session = NSURLSession.sharedSession()
    let task = session.dataTaskWithURL(url) { (let data, let response, let error) in
        endLoading(error: error)
    }
    task.resume()
}

    StatefulViewController

    10/17/2014

    A view controller subclass that presents placeholder views based on content, loading, error or empty states.。

  • It includes a many options for controlling how your popup appears and behaves.

Please feel free to contribute to this project, open issues, make suggestions and submit pull-requests. If you use this project in your app, let me know. I'd love to see what you do with it.

    CNPPopupController

    10/16/2014

    CNPPopupController is a simple and versatile class for presenting a custom popup in a variety of fashions.。

  • Wethr provides developers the ability to add location-based current weather conditions to their views as simply as adding any UIView. All you need to do is set up the frame and add it to your view and we'll handle getting the current weather conditions based on the user's location.

    WethrView *wethrView = [[WethrView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
    [self.view addSubview:wethrView];

    Wethr

    10/16/2014

    Wethr provides developers the ability to add location-based current weather conditions 。

  • TimeLine control is a simple drop in solution to show progress of some event e.g. track order

To use it in your application follow this steps:

drag TimeLineControl folder to project
import "TimeLineViewControl.h"
and initialize view
NSArray *times = @[@"sun",@"mon",@"tue",@"wed",@"thr",@"fri",@"sat"];
NSArray *descriptions = @[@"state 1",@"state 2",@"state 3",@"state 4",@"very very long description if state 5",@"state 6",@"state 7"];
TimeLineViewControl *timeline = [[TimeLineViewControl alloc] initWithTimeArray:times
                                                       andTimeDescriptionArray:descriptions
                                                              andCurrentStatus:4];
timeline.center = self.view.center;
[self.view addSubview:timeline];
To deal with autoLayOut I've used Masonry library. It lays inside Timeline control folder. You don't need to do some additional steps to deal with it, just something to be aware of =)

That is it!

You can check ExampleProject to see how timeline works

    timeLineiOS

    10/16/2014

    A simple drop in solution to show progress of some event。

  • Simple style and Simple way to integrate pull down refresh and pull up fresh
#import "UIScrollView+DXRefresh.h"
[self.tableView addFooterWithTarget:self action:@selector(refreshFooter)];

    DXRefresh

    10/15/2014

    Simple style and Simple way to integrate pull down refresh and pull up fresh。

  • OTCover *test = [[OTCover alloc] initWithTableViewWithHeaderImage:[UIImage imageNamed:@"image.png"] withOTCoverHeight:200];

    OTCover

    10/15/2014

    An view like Medium Personal page for iOS。

  • Animated Alert View written in Swift but ported to Objective-C, which can be used as a UIAlertView or UIAlertController replacement.

    SCLAlertView

    10/15/2014

    Animated Alert View, which can be used as a UIAlertView or UIAlertController replacement.。

  • Add input validation to your text fields. Give the user visual feedback of the validation result! Validation failed? Shake the text field! Validation passed? Show an accept button which allows to end editing and hide the keyboard!

    CKTextField

    10/15/2014

    Enhanced UITextField, with improved visuals for a sweet UX.。

  • A simple line chart library for iOS that is easily adjustable (size, color, line width, label displayed,...). It comes with a nice and subtle appearing animation.

    FSLineChart

    10/15/2014

    A simple line chart library for iOS that is easily adjustable.。

  • CHPlaceholder *placeholder = [[CHPlaceholder alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
placeholder.backgroundColor = [UIColor clearColor];
placeholder.arrowColor = [UIColor blackColor];
placeholder.arrowWidth = 5;

    CHPlaceholder

    10/14/2014

    Placeholder views for iOS.。

  • If you unhide the viewBarrier you can then see the view size that is adjusting the images.

    BRBubbles

    10/14/2014

    Recreating the Watch main interface.。

Popular Code

More >
  • 实现可以点击下拉展开的table cell,可以用作下拉菜单等。
小编注:感谢开发者@_old_fox 分享代码于Code4App。

    Expandable UITableViewCell

    3055 downloads

    Click to expand the UITableViewCell。

  • 实现效果很棒的展开 table cell 显示更多内容的列表功能。

    HVTableView

    2818 downloads

    UITableView with expand/collapse feature (fully animatable)。

  • 显示一组环拍照片,可用于360度展示物品。可以加载压缩成zip文件的一组图片,这样可以缩小整个app的大小。
小编注:感谢开发者@里脊串 发布代码于Code4App.com。

    MMSpinImageView

    1945 downloads

    A UIView to show 360 degree spin photography。

  • 实现特殊效果的UITabBar(Jamie's Recipes App的tab bar效果),开发者可以根据这份代码学习如何自定义UITabBar,包括背景、图片、以及切换动画效果等等。

    Recipe SegmentControl

    1883 downloads

    A demo project that demonstrates how to create a Jamie's Recipes style segment control。

  • 使用简单的代码,实现了汽车的透视效果。可以延伸到人体骨骼扫描等应用。
小编注:基本原理是,界面上有两张图片,底部的图片一开始不可见。随着手指的移动,手指移到的地方,就显示底部的图片,从而实现了第一层图片的透视功能。感谢开发者@谢伟Wayne 分享代码于Code4App。

    transparent view

    1804 downloads

    Implement transparent view demo。

  • 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。

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

    Dial Menu

    1677 downloads

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