Recently Added iOS Source Code Examples

More >
  • iOS Gesture Lock can Create,Check,Modify and Clean.
Copy the folder "LLLock" in demo to your project.
See the detail in the demo.

    lugede-LLLock

    11/21/2014

    iOS Gesture Lock can Create,Check,Modify and Clean。

  • DKTextField is A TextField can change between text and secret code.

Easy to use like simple TextField.

    DKTextField

    11/21/2014

    A TextField can change between text and secret code。

  • Support:
-Supports iPad and iPhone
-Supports landscape and portrait orientations
-Can be used inside UINavigationController
-Customizable badges

CocoaPods

If you're using CocoaPods, simply add pod 'RDVTabBarController' to your Podfile.

Drag & Drop

Add the items from RDVTabBarController directory to your project. If you don't have ARC enabled, you will need to set a -fobjc-arc compiler flag on the .m source files.

Example Usage

Initialize RDVTabBarController

The initialization is similar to the one for UITabBarController. Create an instance of the tabBarController and initialize its viewControllers.

UIViewController *firstViewController = [[RDVFirstViewController alloc] init];
UIViewController *firstNavigationController = [[UINavigationController alloc]
                                               initWithRootViewController:firstViewController];

UIViewController *secondViewController = [[RDVSecondViewController alloc] init];
UIViewController *secondNavigationController = [[UINavigationController alloc]
                                                initWithRootViewController:secondViewController];

UIViewController *thirdViewController = [[RDVThirdViewController alloc] init];
UIViewController *thirdNavigationController = [[UINavigationController alloc]
                                               initWithRootViewController:thirdViewController];

RDVTabBarController *tabBarController = [[RDVTabBarController alloc] init];
[tabBarController setViewControllers:@[firstNavigationController, secondNavigationController,
                                       thirdNavigationController]];
self.viewController = tabBarController;
Customize RDVTabBarController

Each RDVTabBarItem has selectedBackground, unselectedBackground and corresponding properties for the icons: selectedImage and unselectedImage.

UIImage *finishedImage = [UIImage imageNamed:@"tabbar_selected_background"];
UIImage *unfinishedImage = [UIImage imageNamed:@"tabbar_normal_background"];
NSArray *tabBarItemImages = @[@"first", @"second", @"third"];

RDVTabBar *tabBar = [tabBarController tabBar];

[tabBar setFrame:CGRectMake(CGRectGetMinX(tabBar.frame), CGRectGetMinY(tabBar.frame), CGRectGetWidth(tabBar.frame), 63)];

NSInteger index = 0;
for (RDVTabBarItem *item in [[tabBarController tabBar] items]) {
    [item setBackgroundSelectedImage:finishedImage withUnselectedImage:unfinishedImage];
    UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",
                                                  [tabBarItemImages objectAtIndex:index]]];
    UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",
                                                    [tabBarItemImages objectAtIndex:index]]];
    [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];

    index++;
}

    RDVTabBarController

    11/21/2014

    Highly customizable tabBar and tabBarController for iOS。

  • DKTagCloudView is a tag clouds view on iOS. It can generate a random and not intersects coordinates.

How To Get Started

Installation with CocoaPods

$ pod search DKTagCloudView

-> DKTagCloudView (1.0.0)
   A tag clouds view on iOS.t can generate a random and not intersects
   coordinates.
   pod 'DKTagCloudView', '~> 1.0.0'
   - Homepage: https://github.com/zhangao0086/DKTagCloudView
   - Source:   https://github.com/zhangao0086/DKTagCloudView.git
   - Versions: 1.0.0 [master repo]
Edit your Podfile and add DKTagCloudView:

pod 'DKCarouselView', '~> x.x.x'
Add #import "DKTagCloudView.h" to the top of classes that will use it.

Create instances (Also supports xib/storyboard) :

DKTagCloudView *tagCloudView = [[DKTagCloudView alloc] initWithFrame:CGRectMake(0, 64,
                                                                                self.view.bounds.size.width,
                                                                               self.view.bounds.size.height - 64)];
[self.view addSubview:tagCloudView];
self.tagCloudView = tagCloudView;

Setup items:
self.tagCloudView.titls = @[
                         @"DKTagCloudView",@"minFontSize",@"maxFontSize",
.......
                            ];
Generates:
[self.tagCloudView generate];

Callback:
[self.tagCloudView setTagClickBlock:^(NSString *title, NSInteger index) {
    NSLog(@"title:%@,index:%zd",title,index);
}];

    DKTagCloudView

    11/21/2014

    A tag clouds view on iOS.。

  • Subclassed UITableView/UICollectionView cells that will auto calculate their size so long as AutoLayout constraints are applied correctly. For iOS 7+. Works similar to how iOS 8's auto sizing of cells work.

Cocoapods

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

Add a pod entry for HTKScrollingNavigationController to your Podfile pod 'HTKDynamicResizingCell', '~> 0.0.1'
Install the pod(s) by running pod install.
Subclass HTKDynamicResizingTableViewCell or HTKDynamicResizingCollectionViewCell where you wish to use it.
Make sure Auto-layout is setup correctly. See comments in classes for help.
Autolayout Tips:

For AutoLayout to be correct, make sure you complete the following:

For height to calculate correctly, set hugging/compression priorites for all labels. This is one of the most important aspects of having the cell size itself. setContentCompressionResistancePriority needs to be set for all labels to UILayoutPriorityRequired on the Vertical axis. This prevents the label from shrinking to satisfy constraints and will not cut off any text. i.e. [self.label setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];

Set PreferredMaxLayoutWidth for all labels that will have a auto height. This should equal width of cell minus any buffers on sides. i.e self.label.preferredMaxLayoutWidth = defaultSize - buffers;

Set any imageView's images correctly so they have proper size. Remember if you don't set a fixed width/height on a UIImageView it will use the 1x intrinsic size of the image to calculate a constraint. So if your image isn't sized correctly it will produce an incorrect value.

    HTKDynamicResizingCell

    11/20/2014

    Subclassed UITableView/UICollectionView cells that will auto calculate their size so long as AutoLayout constraints are applied correctly。

  • Usage

Make your view controller extend LTSlidingViewController, in viewDidLoad:

self.animator = [[LTSlidingViewCoverflowTransition alloc]init]; // set the animator

UIViewController *vc1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc"];
UIViewController *vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc"];
UIViewController *vc3 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc"];

[self addChildViewController:vc1];
[self addChildViewController:vc2];
[self addChildViewController:vc3];
And you can create custom transition by implementing LTSlidingViewTransition protocal:

@protocol LTSlidingViewTransition <NSObject>
-(void) updateSourceView:(UIView*) sourceView destinationView:(UIView*) destView withPercent:(CGFloat)percent direction:(SlideDirection)direction;
@end
See the example for details~

    LTSlidingViewController

    11/20/2014

    sliding view controller allowing custom transition。

  • A simple utility class to help achieve Safari's swipe-to-hide effect. The class can be used as a UIScrollViewDelegate or on its own. Check out the example project for simple usage.

Installation

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

pod "AFSwipeToHide"

    AFSwipeToHide

    11/20/2014

    Hide your toolbars with a swipe. Just like Safari for iOS.。

  • Usage

You'll probably be using this in a static tableview. You can set it up like this in your TableViewController:

viewDidLoad

var cell = DVDatePickerTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: nil)
cell.leftLabel.text = "The label for the date picker."
cell.datePicker // The datepicker. Add yourself as a target like you normally would, if required.
cell.datePicker.addTarget(self, action: "datePicked:", forControlEvents: UIControlEvents.ValueChanged)
cell.date // The date. Setting will update the picker view and label.
// Add it to an array of cells or something.
didSelectRowAtIndexPath

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  var cell = self.tableView(tableView, cellForRowAtIndexPath: indexPath)
  if (cell.isKindOfClass(DVDatePickerTableViewCell)) {
    (cell as DVDatePickerTableViewCell).selectedInTableView(tableView)
  }
  self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
heightForRowAtIndexPath

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
  var cell = self.tableView(tableView, cellForRowAtIndexPath: indexPath)
  if (cell.isKindOfClass(DVDatePickerTableViewCell)) {
    return (cell as DVDatePickerTableViewCell).datePickerHeight()
  }
  return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
}

    DVDatePickerTableViewCell

    11/17/2014

    Inline/Expanding date picker for table views.。

  • EAColourfulProgressView is a custom progress view where the current filling colour is generated between two colours, based on the current value.

It takes advantages of IBDesignable and IBInspectable so that you can completely customize with without leaving the Interface Builder.

It gives you the possibility to update the current value by calling:
- (void)updateToCurrentValue:(NSInteger)currentValue animated:(BOOL)animated;

Installation Cocoapods

Add this in your Podfile

pod 'EAColourfulProgressView', '~> 0.1.0'
Usage

Set the Custom Class of a UIView to EAColourfulProgressView in Interface Builder, customize the available variables and see them being live rendered ;)

    EAColourfulProgressView

    11/17/2014

    Custom progress view where the current filling colour is generated between two colours, based on the current value。

  • MDMenuViewController is an iOS container view controller that coordinates between its content view controllers through a side menu that is shown from the side with appealing animation , supports iOS 6.0 , 7.0 , 8.0 ,iPhone ,And iPad , Customisable in almost every aspect ,provided with documentation ,And a demo app to get you going right away.

    MDMenuViewController

    11/17/2014

    an iOS container view controller that coordinates between its content view controllers through a side menu。

  • In iOS7 Apple introduced new face features detection to the CIDetecor.CIDetectorEyeBlink, CIDetectorSmile

Ever since i was wondering if i could "feed" it streaming video and maybe make NEW kind of gestures- facial gestures.

Installing:
Using cocoapods:
pod 'DSFacialGestureDetector'
or import all the files under the Detector directory to your project.

Using:
In your view controler:
#import <DSFacialGestureDetector/DSFacialGesturesDetector.h>
implement: <DSFacialDetectorDelegate>
init:
self.facialGesturesDetector = [DSFacialGesturesDetector new];
self.facialGesturesDetector.delegate = self;
self.facialGesturesDetector.cameraPreviewView = self.cameraPreview;
NSError *error;
[self.facialGesturesDetector startDetection:&error;];
See also example project.

    DSFacialGestureDetector

    11/17/2014

    CIDetector with streaming video。

  • Scream.swift is a wrapper for UIKit that lets you replace target and selector with closure.

Example
Usually in UIViewController:

func clicked {
  // Do something
}

func repeated {
  // Do something
}

func viewDidLoad {
    self.button = UIButton.buttonWithType(.Custom) as UIButton
    //Custom button
    ....
    self.buton.addTarget(self, action: "clicked", forControlEvents: UIControlEvents.TouchUpInside)
    self.buton.addTarget(self, action: "repeated", forControlEvents: UIControlEvents.TouchDownRepeat)

}
Let's replace target and selector with closure using Scream.swift.

func viewDidLoad {
    self.button = (UIButton.buttonWithType(.Custom) as UIButton).now{ btn in
      //Custom button
      ...
    }.clicked { btn in
      //Do something
    }.when(label:"repeat") {
      //Do something
    }
}

    Screamswift

    11/17/2014

    UIKit's extensions to use closure in Swift。

  • KWStepper is a stepper control written in Swift. Unlike UIStepper, KWStepper allows for a fully customized UI and provides optional delegate methods for tailoring the UX.

Installation

KWStepper is available on CocoaPods, but it doesn't yet work per this issue. For now, simply copy the files in the KWStepper directory into your project.

Usage

Try the demo!

var stepper: KWStepper?

@IBOutlet weak var countLabel: UILabel!
@IBOutlet weak var decrementButton: UIButton!
@IBOutlet weak var incrementButton: UIButton!
self.stepper = KWStepper(
    decrementButton: self.decrementButton,
    incrementButton: self.incrementButton)

if let stepper = self.stepper {
    stepper.addTarget(self,
        action: Selector("stepperDidChange"),
        forControlEvents: .ValueChanged)
}
func stepperDidChange() {
    self.countLabel.text = NSString(format: "%.f", self.stepper!.value)
}
Properties

The properties of KWStepper are identical to UIStepper with the following exceptions:

Instead of a single stepValue property, KWStepper provides decrementStepValue and incrementStepValue properties for setting different decrement and increment steps.
There is a delegate property that should be set when adhering to the KWStepperDelegate protocol.
During user interaction, change events are sent immediately when the value changes–there is no continuous property.
KWStepperDelegate

Adopting KWStepperDelegate provides the following optional delegate methods for tailoring the UX.

optional func KWStepperDidDecrement()
optional func KWStepperDidIncrement()
optional func KWStepperMaxValueClamped()
optional func KWStepperMinValueClamped()
In the demo, KWStepperMaxValueClamped() and KWStepperMinValueClamped() are used to show a UIAlertView when a limit is reached and the wraps property is set to false.

In Counters•, KWStepperDidDecrement() and KWStepperDidIncrement() are used to play different sounds when decrementing and incrementing the steppers.

    KWStepper

    11/14/2014

    A stepper control with flexible UI and tailored UX。

  • GGTabBar is a simple UITabBar & UITabBarController replacement that uses Auto Layout for constructing the GUI. I created it for curiosity, but it may be useful to others who adventure into the land of Auto Layout.

Install
Just copy the GGTabBar folder into your Xcode project.

Usage :
#warning: Your UIViewControllers must set their tabBarItem images (selected/normal).

Objective-C
Init and customize:
GGTabBarController *tabBar = [[GGTabBarController alloc] init];
tabBar.tabBarAppearanceSettings = @[kTabBarAppearanceHeight : @(100.0)]; // in points
tabBar.viewControllers = @[vc1, vc2, vc3, vc4];
self.window.rootViewController = tabBar;

Swift
#warning: remember to add GGTabBar.h into your project's Swift Bridging Header.

var tabBar: GGTabBarController = GGTabBarController()
tabBar.tabBarAppearanceSettings = [kTabBarAppearanceHeight : 100.0];
tabBar.viewControllers = [vc1, vc2, vc3, vc4]
self.window!.rootViewController = tabBar

    GGTabBar

    11/14/2014

    Another UITabBar & UITabBarController (iOS Tab Bar) replacement, but uses Auto Layout for arranging it's views hierarchy。

  • SphereMenu is a fun menu powered by UIDynamicAnimator. Inspired by Sphere.
SphereMenuSwift is ShpereMenu in Swift.

Usage:
override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        self.view.backgroundColor = UIColor(red:0.2, green:0.38, blue:0.8, alpha:1)
        let start = UIImage(named: "start")
        let image1 = UIImage(named: "icon-twitter")
        let image2 = UIImage(named: "icon-email")
        let image3 = UIImage(named: "icon-facebook")
        var images:[UIImage] = [image1!,image2!,image3!]
        var menu = SphereMenu(startPoint: CGPointMake(160, 320), startImage: start!, submenuImages:images)
        menu.delegate = self
        self.view.addSubview(menu)

    }

    SphereMenuSwift

    11/14/2014

    An interesting menu power by UIDynamicAnimator in Swift。

  • BFDragGestureRecognizer is a UIGestureRecognizer subclass that can be used to drag views inside a scroll view with automatic scrolling at the edges of the scroll view.

Instructions

Create a Podfile, if you don't have one already. Add the following line.

pod 'BFDragGestureRecognizer'
Run the following command.

pod install
Alternatively, you can just drop the BFDragGestureRecognizer.{h,m} files into your project.

Add the gesture recognizer to the view(s) you want to drag:

BFDragGestureRecognizer *dragRecognizer = [[BFDragGestureRecognizer alloc] init];
[dragRecognizer addTarget:self action:@selector(dragRecognized:)];
[view addGestureRecognizer:dragRecognizer];
Implement the gesture handler method. This is very similar to what you would do using a standard UIPanGestureRecognizer:

- (void)dragRecognized:(BFDragGestureRecognizer *)recognizer {
    UIView *view = recognizer.view;
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        // When the gesture starts, remember the current position.
        _startCenter = view.center;
    } else if (recognizer.state == UIGestureRecognizerStateChanged) {
        // During the gesture, we just add the gesture's translation to the saved original position.
        // The translation will account for the changes in contentOffset caused by auto-scrolling.
        CGPoint translation = [recognizer translationInView:_contentView];
        CGPoint center = CGPointMake(_startCenter.x + translation.x, _startCenter.y + translation.y);
        view.center = center;
    }
}

More Detail in Demo.

    BFDragGestureRecognizer

    11/14/2014

    a UIGestureRecognizer subclass that can be used to drag views inside a scroll view with automatic scrolling at the edges of the scroll view。

  • An easy and useful StatRating View.

How to use:

#import "CWStarRateView.h"

self.starRateView = [[CWStarRateView alloc] initWithFrame:CGRectMake(10, 100, 300, 40) numberOfStars:5];
    self.starRateView.scorePercent = 0.3;
    self.starRateView.allowIncompleteStar = YES;
    self.starRateView.hasAnimation = YES;
    [self.view addSubview:self.starRateView];

    StarRatingView

    11/11/2014

    An easy and useful StatRating View。

  • DZNSegmentedControlFeatures

-Customizable control with tint color, font, sizes and animation duration.
-Animated and width auto-adjusting selection indicator.
-UIBarPositioning support.
-UIAppearance support.
-ARC & 64bits. ‘

Installation
Available in Cocoa Pods

pod 'DZNSegmentedControl'

How to use:

Step 1
Import "DZNSegmentedControl.h"

Step 2
Creating a new instance of DZNSegmentedControl is very similar to what you would do with UISegmentedControl:

NSArray *items = @[@"Tweets", @"Following", @"Followers"];

DZNSegmentedControl *control = [[DZNSegmentedControl alloc] initWithItems:items];
control.tintColor = [UIColor blueColor];
control.delegate = self;
control.selectedSegmentIndex = 1;

[control addTarget:self action:@selector(selectedSegment:) forControlEvents:UIControlEventValueChanged];
You can additionally set more properties:

[control setCount:@(12) forSegmentAtIndex:0];
[control setTitle:@"Hello" forSegmentAtIndex:1];
[control setEnabled:NO forSegmentAtIndex:2];
Sample project

Take a look into the sample project. Everything is there.

    DZNSegmentedControl

    11/11/2014

    A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile。

Popular Code

More >
  • cocos2d 高仿捕鱼达人。
小编注:十分感谢@念风2012 分享如此高质量的代码于Code4App。想学习cocos2d的筒子赶紧下载啊!

    cocos2d fishing game

    3025 downloads

    Use cocos2d implement popular fishing game。

  • 实现效果不错的可展开cell的列表(TableView)。列表cell最左边的accessory 在cell展开的时候会发生变化。

    SKSTableView

    2512 downloads

    An expandable table view。

  • 自定义UITabBar,包括可自定义tab bar的背景图、tab bar的高度以及每个tab的图片,满足各种界面需求。但是,没有文字。
小编注:感谢开发者@-_夜游神_- 分享代码于Code4App。

    Customize UITabBar

    2397 downloads

    Customize UITabBar。

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

    Metal Slug Demo

    2116 downloads

    Metal Slug demo made by cocos2d。

  • 将来自互联网的图片或者本地相册的照片按照时间顺序放在列表中显示。

    Photo Collection Controller

    1738 downloads

    REPhotoCollectionController is a photo thumbnail viewer for the iOS that groups photos by date。

  • 利用cocos2d制作的坦克大战游戏。实现效果(包括音效)非常不错。
作者说:回顾经典fc永远少不了tank大战,分享学习cocos2d过程中写的tank大战源码,希望能帮助正在学习cocos2d的同学。
小编注:感谢开发者@xzicoke 分享代码于code4app。

    tank game

    1722 downloads

    A tank game made by cocos2d。

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

    URBAlertView

    1624 downloads

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