Recently Added iOS Source Code Examples

More >
  • DKNightVersion is a light weight framework. It's mainly built through objc/runtime library and reflection, providing a neat approach adding night mode to your iOS app. A great many codes of this framework is automatically generated by Ruby script.

The most delightful feature of DKNightVersion is that it appends one more property nightColor to frequently-used UIKit components and provides you a default night mode theme. It is easily-used and well-designed. Hope you have a great joy to use DKNightVersion to integrate night mode in your Apps.

Podfile

pod "DKNightVersion", "~> 0.7.0"
Usage

Just add one line of code in your precompiled header, or import it where you need.

#import "DKNightVersion.h"
How to use
Using night color

DKNightVersion is based on property nightColor, such as nightBackgroundColor nightTextColor and etc.

Assign the night mode color you want to the UIKit component like this:

self.view.nightBackgroundColor = [UIColor blackColor];
self.label.nightTextColor = [UIColor whiteColor];
Using DKNightVersionManager change theme

Use DKNightVersionManager sets the theme.

[DKNightVersionManager nightFalling];
If you'd like to switch back to normal mode:

[DKNightVersionManager dawnComing];
It's pretty easy to swich theme between night and normal mode.

    DKNightVersion

    05/25/2015

    DKNightVersion is a lightweight iOS framework adding night mode to your iOS app。

  • Usage

Create a instance of any UIView subclass.
Call the show(modalView: , inView: ) of PathDynamicModal class-function or instance-function.
For detail, please refer to Demo-project.
Functions

class func show(modalView view: UIView, inView: UIView) -> PathDynamicModal // Show modal with settings default all.
func show(modalView view: UIView, inView: UIView) // Show modal with custom settings.
func closeWithLeansRandom() // Close modal with random slant.
func closeWithStraight() // Close modal with non slant.
func closeWithLeansRight() // Close modal with right slant.
func closeWithLeansLeft() Close modal with left slant.
Property

var backgroundColor: UIColor // Default is UIColor.blackColor()
var backgroundAlpha: CGFloat // Default is 0.7 
var showMagnitude: CGFloat // Default is 250.0. This affects the speed of modal dropping to show.
var closeMagnitude: CGFloat // Default is 170.0. This affects the speed of modal dropping to close.
var closeByTapBackground: Bool // Default is true
var closeBySwipeBackground: Bool // Default is true
var showedHandler: (() -> Void)?
var closedHandler: (() -> Void)?

More detail please refer the demo.

    PathDynamicModal

    05/15/2015

    A modal view using UIDynamicAnimator, like the Path for iOS。

  • A nice and simple tags input control for iOS.

You are able to easily setup different colors for control elements and set different displaying modes

Switching between displaying modes

You are able to switch between displyaing modes by setting the mode property

@property (nonatomic) TLTagsControlMode mode;
TLTagsControl has two displaying modes:

TLTagsControlModeEdit,
This mode allows user to input new tags and delete tags that are already presented.

In this mode control will look like below:

Screenshot

TLTagsControlModeList,
This mode allows only listing of already presented tags

In this mode control will look like below:

Screenshot

Setting different colors of control elements

You are able to change colors of different element by setting these prperties

@property (nonatomic, strong) UIColor *tagsBackgroungColor;
@property (nonatomic, strong) UIColor *tagsTextColor;
@property (nonatomic, strong) UIColor *tagsDeleteButtonColor;
Applying changes

To apply your changes you should call the method below

- (void)reloadTagSubviews;
Example:

//assuming tagControl will be set initialized from stroryboard
@interface ViewController ()

@property (nonatomic, strong) IBOutlet TLTagsControl *tagControl;

@end

....

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  UIColor *blueBackgroundColor = [UIColor colorWithRed:75.0/255.0 green:186.0/255.0 blue:251.0/255.0 alpha:1];
  UIColor *whiteTextColor = [UIColor whiteColor];

  self.tagControl.tagsBackgroungColor = blueBackgroundColor;
  self.tagControl.tagsDeleteButtonColor = whiteTextColor;
  self.tagControl.tagsTextColor = whiteTextColor;

  self.tagControl.mode = TLTagsControlModeList;

  [self.tagControl reloadTagSubviews];
}

@end

    TLTagsControl

    05/15/2015

    A nice and simple tags input control for iOS。

  • A simple control for implementing a beautiful scrolling segment control. With adaptive gradient to tease the user to explore all the items in the list. Fully customizable either by code or using interface builder.

    YAScrollSegmentControl

    05/14/2015

    Beautiful and easy to use scrolling segment control.。

  • KDCircularProgress is a circular progress view written in Swift. It makes it possible to have gradients in the progress view, along with glows and animations.

    KDCircularProgress(Swift)

    05/14/2015

    A circular progress view with gradients written in Swift。

  • Most simple usage:

// Get four dominant colors from the image, but avoid the background color of our UI
CCColorCube *colorCube = [[CCColorCube alloc] init];
UIImage *img = [UIImage imageNamed:@"test2.jpg"];
NSArray *imgColors = [colorCube extractColorsFromImage:img avoidColor:myBackgroundColor co

    ColorCube

    05/11/2015

    Dominant color extraction from RGB images on iOS。

  • SwiftNotice is a GUI library for displaying various popups written in pure Swift, fits any scrollview.

    SwiftNotice

    05/05/2015

    GUI library for displaying various popups, written in pure Swift.。

  • 
Configure
Checkout PPDragDropBadgeView from github.
Copy PPDragDropBadgeView folder to your project.
Go to 'TARGET' -> 'Build Phases' -> 'Complile Sources', add compliler flags '-fno-objc-arc' for 'PRTween.m' and 'PRTweenTimingFunctions.m'
Done.
You can also refer to the example project provided by me.

Usage

Q: How to use PPDragDropBadgeView?
A: Very simple, you only follow the down code.

PPDragDropBadgeView* badgeView \
= [[PPDragDropBadgeView alloc] initWithSuperView:self.testView
                                    location:CGPointMake(0,0)
                                      radius:10.0f dragdropCompletion:^{
                                                     NSLog(@"Drag drop done.");
                                       }];
badgeView.text = @"6";
Q: Does it can be customized?

A: Of course, you can set "location", "radius", "tintColor", "borderWidth", "borderColor". You can see the propertys provided by me.

/** The location of badge view. */
@property (nonatomic, assign) CGPoint location;

/** The radius of badge view. */
@property (nonatomic, assign) CGFloat radius;

/** The completion block when drag drop done. */
@property (nonatomic, copy) void(^dragdropCompletion)();

/** The tint color of badge view. Default is red */
@property (nonatomic, strong) UIColor* tintColor;

/** The border color of badge view. Default is clear */
@property (nonatomic, strong) UIColor* borderColor;

/** The border width of badge view. Default is 1.0f */
@property (nonatomic, assign) CGFloat borderWidth;

/** The text of badge view. */
@property (nonatomic, strong) NSString* text;

    PPDragDropBadgeView

    04/30/2015

    PPDragDropBadgeView is a badge view which able to drag and drop. Just like QQ 5.0 badge view.。

  • Usage

Instantiate and set delegate and dataSource as you know,

self.pickerView = AKPickerView(frame: <#frame#>)
self.pickerView.delegate = self
self.pickerView.dataSource = self
then specify the number of items using AKPickerViewDataSource,

func numberOfItemsInPickerView(pickerView: AKPickerView) -> Int {}
and contents to be shown. You can use either texts or images:

func pickerView(pickerView: AKPickerView, titleForItem item: Int) -> NSString {}
// OR
func pickerView(pickerView: AKPickerView, imageForItem item: Int) -> UIImage {}
Using both texts and images are currently not supported. When you implement both, titleForItem will be called and the other won't.
You currently cannot specify image sizes; AKPickerView shows the original image in its original size. Resize your images in advance if you need.
You can change its appearance with properties below:

var font: UIFont
var highlightedFont: UIFont
var textColor: UIColor
var highlightedTextColor: UIColor
var interitemSpacing: CGFloat
var viewDepth: CGFloat
var pickerViewStyle: AKPickerViewStyle
All cells are laid out depending on the largest font, so large differnce between the sizes of font and highlightedFont is NOT recommended.
viewDepth property affects the perspective distortion. A value near the screen's height or width is recommended.
After all settings, never forget to reload your picker.

self.pickerView.reloadData()
Optional: You can use AKPickerViewDelegate methods to observe selection changes:

func pickerView(pickerView: AKPickerView, didSelectItem item: Int) {}

CocoaPods:

In your Podfile:
pod "AKPickerView-Swift"

And in your *.swift:
import AKPickerView_Swift

    AKPickerView-Swift

    04/24/2015

    A simple yet customizable horizontal picker view。

  • Usage:
self.indicatorView1 = MAActivityIndicatorView(frame: self.viewForActivity1.frame)
            self.indicatorView1.defaultColor = UIColor.redColor()
            self.indicatorView1.animationDuration    = 1
            self.indicatorView1.numberOfCircles      = 15
            self.indicatorView1.maxRadius            = 40
            self.indicatorView1.delegate = self
           // self.indicatorView1.backgroundColor = UIColor.lightGrayColor()
            self.indicatorView1.startAnimating()
            self.view.addSubview(self.indicatorView1)

    MAActivityIndicator

    04/24/2015

    a custom activity indicator with little dots written in Swift。

  • Custom Calendar for iOS Grid Calendar view for iOS created by Jubin Jacob (jubinjacob19@gmail.com) Swipe to change months.

Delegate displays selected date(NSDate) on selection of a date.

Datasource allows some days to be highlighted and the calendar to be « locked » between a starting month and an ending month.

    CustomCalendar

    04/10/2015

    Custom Calendar for iOS。

  • JDFPeekaboo is a simple class that hides the navigation bar when you scroll down, and shows it again when you scroll back up. It can actually be any UIView that it hides, and it will also hide a view at the bottom of the screen as well, if you like.

It's very easy to use. Simply add a property for it:

@property (nonatomic, strong) JDFPeekabooCoordinator *scrollCoordinator;
Then, set it up (say, in -viewDidLoad):

self.scrollCoordinator = [[JDFPeekabooCoordinator alloc] init];
self.scrollCoordinator.scrollView = self.scrollView;
self.scrollCoordinator.topView = self.navigationController.navigationBar;
self.scrollCoordinator.bottomView = self.navigationController.toolbar;
Sometimes, you may want to temporarily disable JDFPeekaboo, for example when you push another view controller onto your navigation controller. Some convenience methods are provided for disabling JDFPeekaboo (and re-enabling it).

    JDFPeekaboo

    04/10/2015

    JDFPeekaboo is a simple class that hides the navigation bar when you scroll。

  • Recreate Twitter's profile page scrolling animation for UITableView and UIScrollViews. Librarys uses Core graphics framework and is based of thinkandbuild.it's swift tutorial converted into Obj-C.

Installation

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

Manually
Copy the source files MBTwitterScroll folder into your project.

Usage
#import "MBTwitterScroll.h"

UITableView

To show animation on UITableVIew use the following code:

    MBTwitterScroll *myTableView = [[MBTwitterScroll alloc]
                                    initTableViewWithBackgound:[UIImage imageNamed:@"your image"]
                                    avatarImage:[UIImage imageNamed:@"your avatar"]
                                    titleString:@"Main title"
                                    subtitleString:@"Sub title"
                                    buttonTitle:@"Follow"];  // Set nil for no button
    myTableView.delegate = self;
    [self.view addSubview:myTableView];


UIScrollView

To show animation on UIScrollView use the following code:

   MBTwitterScroll *myScrollView = [[MBTwitterScroll alloc]
                                      initScrollViewWithBackgound:nil
                                      avatarImage:[UIImage imageNamed:@"avatar.png"]
                                      titleString:@"Main title"
                                      subtitleString:@"Sub title"
                                      buttonTitle:@"Follow" // // Set nil for no button
                                      contentHeight:2000];
    myScrollView.delegate = self;
    [self.view addSubview:myScrollView];

    MBTwitterScroll

    03/30/2015

    Recreate Twitter's profile page scrolling animation for UITableView and UIScrollViews。

  • Installation

The easiest way to get started is to use CocoaPods. Add the following line to your Podfile:
platform :ios, '8.0'
use_frameworks!
# The following is a Library of Swift.
pod 'MediumMenu'
Then, run the following command:

pod install
Or add the MediumMenu (including MediumMenu.swift) folder into your project.

Due to the lack of choice whether status bar is hidden or not, Edit info.plist in your project.

Add "Status bar is initially hidden" and "View controller-based status bar appearance" in info.plist as key. Eash value is "YES" and "NO".

In the rest of the details, refer to MediumMenu-Sample project.

    MediumMenu

    03/30/2015

    A menu based on Medium iOS app。

  • You can use secret command with swipe gesture and A, B button. Show a secret mode you want!
Features
-Secret command register
-Unlock with secret command
- Show input command with animation

Installation

CocoaPods
SASecretCommandViewController is available through CocoaPods. If you have cocoapods 0.36 beta or greater, you can install it, simply add the following line to your Podfile:
pod "SASecretCommandViewController"

Manually
Add the SASecretCommandViewController directory to your project.

See the example project for the detail usage.

    SASecretCommandViewController

    03/27/2015

    SASecretCommandViewController。

  • HoleView, holes methods

- (NSInteger)addHoleCircleCenteredOnPosition:(CGPoint)centerPoint andDiameter:(CGFloat)diamter;
- (NSInteger)addHoleRectOnRect:(CGRect)rect;
- (NSInteger)addHoleRoundedRectOnRect:(CGRect)rect withCornerRadius:(CGFloat)cornerRadius;
- (NSInteger)addHCustomView:(UIView *)customView onRect:(CGRect)rect;

HoleView Delegation : JMHoledViewDelegate

This method will be called if you configure a holeViewDelegate. The index is equal to NSNotFound if user touch dimingView.

- (void)holedView:(JMHoledView *)holedView didSelectHoleAtIndex:(NSUInteger)index;

    JMHoledView

    03/27/2015

    A view design to be filled with holes。

  • Usage

Import category #import <UIViewController-KeyboardAdditions/UIViewController+KeyboardAdditions.h>

Register to keyboard notifications in -viewWillAppear::

[self ka_startObservingKeyboardNotifications];
Unregister from notifications in -viewWillDisappear::
[self ka_stopObservingKeyboardNotifications];
Perform any layout with same animation options as keybord:
- (void)ka_keyboardShowOrHideAnimationWithHeight:(CGFloat)height
                               animationDuration:(NSTimeInterval)animationDuration
                                  animationCurve:(UIViewAnimationCurve)animationCurve {

    self.containerViewBottomConstraint.constant = height;
    [self.view layoutIfNeeded];
}

    UIViewControllerKeyboardAdditions

    03/27/2015

    Tiny UIViewController category that provides handy way for keyboard handling logic。

  • ABCIntroView is an easy to use onboarding which allows you to introduce your users to the applicaiton before reaching the Main Screen.

To use the ABCIntroView please do the following:

Add the follwing files found in the CLASSES folder to your project:
        *ABCIntroView.h
        *ABCIntroView.m
Import the ABCIntoView file to your RootViewController.

Create an ABCIntroView property and add the ABCIntroViewDelegate.

Add the following line of code to your ViewDidLoad:

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if (![defaults objectForKey:@"intro_screen_viewed"]) {
        self.introView = [[ABCIntroView alloc] initWithFrame:self.view.frame];
        self.introView.delegate = self;
        self.introView.backgroundColor = [UIColor greenColor];
        [self.view addSubview:self.introView];  
    }
Add the ABCIntroView Delegate Method:
#pragma mark - ABCIntroViewDelegate Methods

-(void)onDoneButtonPressed{
    //    Uncomment so that the IntroView does not show after the user clicks "DONE"
    //    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]
    //    [defaults setObject:@"YES"forKey:@"intro_screen_viewed"];
    //    [defaults synchronize];
    [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.introView.alpha = 0;
    } completion:^(BOOL finished) {
        [self.introView removeFromSuperview];
    }];
}

    ABCIntroView

    03/27/2015

    an easy to use onboarding which allows you to introduce your users to the applicaiton before reaching the Main Screen。

Popular Code

More >
  • 基于ASIHTTP 的多线程下载管理功能模块,支持异步下载、暂停和恢复下载等等功能。暂停某个下载任务,再次恢复该下载任务时,不会重头下载,而是在已下载的地方开始下载(即断点下载)。具体有如下特色:
1. 完整的UI设计,可直接拿来使用;
2. 异步,后台,多线程(ASI提供);
3. 最大同时下载数设置;
4. 下载任务排队,暂停,等待,继续,删除某个下载任务;
5. 记录下载的未完成和已完成任务,并在下次启动时加载;
作者说:如有问题请email:tigerandy@163.com。
小编注:感谢开发者@Sven 发布代码于 Code4App.com。

    DownLoadManager

    2861 downloads

    Download mangement based on ASIHTTP, support pause\resume download task, multiple threads download。

  • 实现较为完整的图片浏览器(Photo Browser),整体效果和ios自带的照片app差不多。包括的功能有:手指划动切换图片,点击图片隐藏导航条,放大图片、分享图片、复制图片等等。显示的图片包括本地图片、相册图片、网络图片。并且能够处理下载和cache(缓存)来自互联网图片。

    Photo Browser

    1970 downloads

    A photo browser similar to the native Photos app in iOS。

  • 实现cover flow效果, 处于中间位置的图片亮度和大小都突出于旁边的图片。当滑动cover flow时,旁边的图片随着位移会慢慢变大和变亮。
@flycent_stars 在使用这份代码时遇到一点问题,提出了他自己的解决方案:这个代码中reloaddata后,调用layoutsubviews应移除掉之前的subviews,然后加上[[_scrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];即可。
感谢@@flycent_stars 。

    Paged Flow View

    1733 downloads

    A Paging Enabled Flow View, like screenshots view in iPhone App Store。

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

    tank game

    1722 downloads

    A tank game made by cocos2d。

  • 实现类似搜狐新闻的UI架构,顶部滑条可以点击切换视图,也可以直接滑动屏幕切换视图。
小编注:感谢作者@刘嘉雁过留名 发布原创代码于Code4App。另外一位作者@啊婆在移动-楊國平 对这份代码进行了封装,直接实例化就能使用(http://code4app.com/ios/51dfa52b6803fa9368000000)。

    Slide transition tabbar

    1676 downloads

    Can slide the tab bar for view transition。

  • 使 UIScrollView 中的图片支持手势缩放。双击图片可以放大图片,或者pinch(捏合)手势可以缩放图片。基本原理是UIScrollView中嵌套UIScrollView,然后再嵌套UIImageView,可对UIImageView进行伸缩。
小编注:美中不足是,缩放的图片,再滑动到其他图片,然后再滑动回来,之前缩放的图片没有恢复原来大小。感谢作者@Hello我的青春 分享代码于Code4App。

    Pinch ScrollView Image

    1633 downloads

    Pinch to zoom in and zoom out the images displayed on the UIScrollView。

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

    Location Manager

    1595 downloads

    Easy Location Manager Framework。