你好,歡迎來到IOS教程網

 Ios教程網 >> IOS使用技巧 >> IOS技巧綜合 >> iOS學習之常用第三方框架總結(經典/必看)

iOS學習之常用第三方框架總結(經典/必看)

編輯:IOS技巧綜合
[摘要]本文是對iOS學習之常用第三方框架總結(經典/必看)的講解,對學習IOS蘋果軟件開發有所幫助,與大家分享。

寫iOS 程序的時候往往需要很多第三方框架的支持,可以大大減少工作量,講重點放在軟件本身的邏輯實現上。

GitHub 裡面有大量優秀的第三方框架,而且 License 對商業很友好。一下摘錄一下幾乎每個項目都想集成的幾個框架。

SDWebImageView

1. Mantle

Mantle 讓我們能簡化 Cocoa 和 Cocoa Touch 應用的 model 層。簡單點說,程序中經常要進行網絡請求,請求到得一般是 json 字符串,我們一般會建一個 Model 類來存放這些數據。這就要求我們編寫一系列的序列化代碼,來把 json 轉換為 Model 。這很費時間,容易錯,不容易修改。 Mantle 很好的解決了這個問題,而且更易用。

    GitHub :https://github.com/Mantle/Mantle

    參考:

    工具篇: Mantle
    源碼篇: Mantle

    CocoaPod 集成: pod 'Mantle', '~> 1.5.4'

2. Masonry

IB 時代,如果你還在用代碼絕對布局就太 low 了。隨著蘋果發布 iPhone6 、 iPhone 6 plus 。 iOS 設備將會出現越來越豐富的屏幕尺寸,我們不可能根據每個尺寸做一套布局。所以,使用 autolayout 就很有必要了。在 storyboard 中,可以非常方便的使用 autolayout ,但是為了更好的協作開發,有些公司依然在手寫布局,令人沮喪的是蘋果提供的 autolayout 語法晦澀難懂,非常影響效率(你可以在這裡動態查看 autolayout 的語法)。 Masonry 就是設計來解決復雜的手寫 autolayout 。如何優雅的使用 autolayout ,且看 Masonry 。

    GitHub :https://github.com/Masonry/Masonry

    參考:使用方法,請看 README

    CocoaPod 集成: pod 'Masonry', '~> 0.6.1'

3. Reachability

移動互聯網時代,應該很少有應用是不需要網絡連接的吧。監測網絡連接狀態幾乎是必不可少的一部分。 Reachability 可以完美的完成這一任務

    GitHub :https://github.com/tonymillion/Reachability

    參考:使用方法非常簡單,請看 README

    CocoaPod 集成: pod 'Reachability', '~> 3.2'

4. BlocksKit

BlocksKit絕對是 Objective-C 的知心伴侶,它為 OC 常用類提供了強大的 Block 語法支持,使得編寫 OC 代碼變得舒適、快速、優雅。反正我是絕對離不開它。

    GitHub :https://github.com/zwaldowski/BlocksKit

    參考:block 使用小結、在 arc 中使用 block 、如何防止循環引用 (zz)

    CocoaPod 集成: pod 'BlocksKit', '~> 2.2.5'

5. KVOController

如果你在項目中有使用 KVO ,那麼 KVOController 絕對是個好選擇。它是 facebook 開源的一個 KVO 增強框架。有以下幾個特性:

    使用 Blocks 、自定義 Actions 或者 NSKeyValueObserving 回調進行通知 .

    觀測者移除時無異常

    控制器 dealloc 時隱式的觀測者移除

    提升使用 NSKeyValueObservingInitial的性能

    線程安全並提供在觀測者恢復時額外的保護

    還有什麼理由不使用 KVOController 呢?

    GitHub :https://github.com/facebook/KVOController

    參考:KVOController : facebook 開源的 KVO ( Key-value Observing )工具

    CocoaPod : pod 'KVOController', '~> 1.0.3'

6. MBProgressHUD

一個老牌、經典的通知組件,如果你們美工沒有專門設計等待和通知視圖,那就用它吧!

    GitHub :https://github.com/jdg/MBProgressHUD

    參考

    CocoaPod : pod 'MBProgressHUD', '~> 0.9'

7. ODRefreshControl

很多公司都自己設計下拉刷新視圖,比如網易新聞 iOS 客戶端,下拉的時候會有廣告出現。如果你只是需要一個下拉刷新,那麼可以考慮 ODRefreshControl ,它是原 iOS6 上的橡皮糖刷新樣式,很有意思。現在也很多大的 App 在用,比如蝦米音樂和 QQ 客戶端。

    GitHub :https://github.com/Sephiroth87/ODRefreshControl

    參考

    CocoaPod : pod 'ODRefreshControl', '~> 1.1.0'

8. pop

又是 Facebook 開源的。大名鼎鼎的 pop ,做動畫的不二之選。收下它吧。

    GitHub :https://github.com/facebook/pop

    參考:Facebook Pop 使用指南popping(pop 的使用實例 )

    CocoaPod : pod 'pop', '~> 1.0.7'

9. AFNetworking

Objective-C下網絡請求庫。

    GitHub :https://github.com/AFNetworking/AFNetworking

    參考

    CocoaPod : pod 'AFNetworking', '~> 2.5.0'

SVProgressHUD 提示效果

GitHub:https://github.com/samvermette/SVProgressHUD

SVProgressHUD和MBProgressHUD效果差不多,不過不需要使用協議,同時也不需要聲明實例。

直接通過類方法進行調用即可:

[SVProgressHUD method]

可以使用以下方法來顯示狀態:

+ (void)show;+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;+ (void)showWithStatus:(NSString*)string;+ (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType;

如果需要明確的進度,則使用以下方法:

+ (void)showProgress:(CGFloat)progress;+ (void)showProgress:(CGFloat)progress status:(NSString*)status;+ (void)showProgress:(CGFloat)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType;

通過dismiss方法來隱藏提示:

+ (void)dismiss;

另外提供了以下方法用於顯示狀態,並在1秒後自動隱藏提示(使用的圖標來源於Glyphish:http://www.glyphish.com/):

+ (void)showSuccessWithStatus:(NSString*)string;+ (void)showErrorWithStatus:(NSString *)string;+ (void)showImage:(UIImage*)image status:(NSString*)string; // use 28x28 white pngs

ZAActivityBar 提示效果

GitHub:https://github.com/zacaltman/ZAActivityBar

ZAActivityBar和SVProgressHUD非常相似,它提供了更加簡潔的API來顯示提示效果。

ZAActivityBar使用的動畫效果來源於ZKBounceAnimation(https://github.com/khanlou/SKBounceAnimation),成功、失敗的狀態圖標來源於Pictos(http://pictos.cc/)。

顯示加載狀態:

[ZAActivityBar showWithStatus:@"加載中..."];

顯示成功、失敗狀態:

[ZAActivityBar showSuccessWithStatus:@"成功!"];[ZAActivityBar showErrorWithStatus:@"失敗!"];

隱藏提示:

[ZAActivityBar dismiss];

官方: http://sbjson.org/

GitHub:https://github.com/stig/json-framework

UIActivityIndicator-for-SDWebImage 為SDWebImage顯示加載效果

GitHub:https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage

用於為SDWebImage在UIImageView加載圖片時,顯示加載效果(UIActivityIndicatorView實現),它提供以下方法:

- (void)setImageWithURL:(NSURL *)url usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock usingActivityIndicatorStyle:(UIActivityIndicatorViewStyle)activityStyle;

UIImage+Resize 調整圖片大小

GitHub:https://github.com/coryalder/UIImage_Resize

提供多種方法為圖片設置透明度、圓角、裁剪、調整大小等:

- (UIImage *)imageWithAlpha;- (UIImage *)transparentBorderImage:(NSUInteger)borderSize;- (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize;- (UIImage *)croppedImage:(CGRect)bounds;- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize          transparentBorder:(NSUInteger)borderSize               cornerRadius:(NSUInteger)cornerRadius       interpolationQuality:(CGInterpolationQuality)quality;- (UIImage *)resizedImage:(CGSize)newSize     interpolationQuality:(CGInterpolationQuality)quality;- (UIImage *)  resizedImageWithContentMode:(UIViewContentMode)contentMode                       bounds:(CGSize)bounds         interpolationQuality:(CGInterpolationQuality)quality;

更詳細使用見:http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

ImageCacheResize 異步加載圖片、緩存及調整大小

GitHub:https://github.com/toptierlabs/ImageCacheResize

整合了SDWebImage和UIImage+Resize的功能,用於圖片的異步加載、緩存、以及下載完成後調整大小並顯示在UIImageView上。

提供了以下API用於加載圖片以及加載完成後調整圖片大小:

- (void)setImageWithURL:(NSURL *)url andCropToBounds:(CGRect)bounds;- (void)setImageWithURL:(NSURL *)url andResize:(CGSize)size withContentMode:(UIViewContentMode)mode;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder andCropToBounds:(CGRect)bounds;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options  andResize:(CGSize)size;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options  andResize:(CGSize)size withContentMode:(UIViewContentMode)mode;- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options  andCropToBounds:(CGRect)bounds;

使用方法和SDWebImage一樣簡單,如以下官方例子:

[imageview setImageWithURL:[NSURL URLWithString:@"http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A"] andResize:CGSizeMake(30, 30) withContentMode:UIViewContentModeScaleAspectFit]; // 按比例縮放[imageview setImageWithURL:[NSURL URLWithString:@"http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A"] andCropToBounds:CGRectMake(0, 0, 100, 100)]; // 裁剪成100x100大小

STableViewController 下拉刷新、上拉加載更多

GitHub:https://github.com/shiki/STableViewController

STableViewController比PullToRefresh多了一個上拉加載更多功能,使用上也差不多簡單,需要繼承自STableViewController,再實現一些方法:

- (void) viewDidLoad{  [super viewDidLoad];    self.title = @"STableViewController Demo";  [self.tableView setBackgroundColor:[UIColor lightGrayColor]];    // 需要創建兩個自定義視圖用於顯示"下拉刷新"、"上拉加載更多"  self.headerView = headerView;    self.footerView = footerView;  }#pragma mark - Pull to Refresh- (void) pinHeaderView{  [super pinHeaderView];    // 下拉刷新視圖顯示一些加載動畫}- (void) unpinHeaderView{  [super unpinHeaderView];    // 下拉刷新視圖停止動畫}- (void) headerViewDidScroll:(BOOL)willRefreshOnRelease scrollView:(UIScrollView *)scrollView{  // 下拉刷新視圖顯示狀態信息  if (willRefreshOnRelease)    //hv.title.text = @"松開後刷新...";  else    //hv.title.text = @"下拉刷新...";}- (BOOL) refresh{  if (![super refresh])    return NO;    // 下拉刷新加載數據  [self performSelector:@selector(addItemsOnTop) withObject:nil afterDelay:2.0];  return YES;}#pragma mark - Load More- (void) willBeginLoadingMore{  // 上拉加載更多視圖加載動畫}- (void) loadMoreCompleted{  [super loadMoreCompleted];  // 上拉加載更多視圖停止動畫    if (!self.canLoadMore) {    //沒有更多數據的時候執行代碼...  }}- (BOOL) loadMore{  if (![super loadMore])    return NO;    // 上拉加載更多數據  [self performSelector:@selector(addItemsOnBottom) withObject:nil afterDelay:2.0];  return YES;}// - (void) addItemsOnTop{  // 加載數據...    [self.tableView reloadData];    // 數據加載完成通知上拉視圖  [self refreshCompleted];}- (void) addItemsOnBottom{  // 加載更多數據...  [self.tableView reloadData];    // 通過判斷設置是否可以加載更多  //self.canLoadMore = NO;    // 數據加載完成通知下拉視圖  [self loadMoreCompleted];}

SVPullToRefresh 下拉刷新、上拉加載更多

GitHub:https://github.com/samvermette/SVPullToRefresh

包含SVPullToRefresh + SVInfiniteScrolling為UITableView提供下拉刷新、上拉加載更多功能。

使用起來也相當簡單,只要在UITableViewController裡實現以下方法:

- (void)viewDidLoad {    [super viewDidLoad];    __weak SVViewController *weakSelf = self;        // 設置下拉刷新    [self.tableView addPullToRefreshWithActionHandler:^{        [weakSelf insertRowAtTop];    }];            // 設置上拉加載更多    [self.tableView addInfiniteScrollingWithActionHandler:^{        [weakSelf insertRowAtBottom];    }];}- (void)viewDidAppear:(BOOL)animated {    [tableView triggerPullToRefresh];}- (void)insertRowAtTop {    // 獲取數據....        // 停止動畫    [self.tableView.pullToRefreshView stopAnimating];}- (void)insertRowAtBottom {    // 獲取數據....        // 停止動畫    [weakSelf.tableView.infiniteScrollingView stopAnimating];}

CMPopTipView 提示信息

GitHub:https://github.com/chrismiles/CMPopTipView

CMPopTipView用於在一些視圖上顯示提示信息:

self.tipView = [[CMPopTipView alloc] initWithMessage:@"提示消息"];self.tipView.delegate = self;[self.tipView presentPointingAtView:anyButton inView:self.view animated:YES]; // 點擊按鈕顯示[self.tipView presentPointingAtBarButtonItem:barButtonItem animated:YES]; // 點擊導航欄按鈕顯示    #pragma mark CMPopTipViewDelegate methods- (void)popTipViewWasDismissedByUser:(CMPopTipView *)popTipView {  // 清理資源  self.tipView = nil;}

GitHub:https://github.com/vicpenap/PrettyKit

定制了一些UI組件如UITableViewCell、UINavigationBar、UITabBar、UIToolBar等,比系統自帶的更加美觀。

GitHub:https://github.com/sobri909/MGBox2

提供一些定制的UI組件可以更簡單快速的創建表格、網格布局,以及豐富的文本呈現,基於block的事件機制等,包含:MGBox、MGTableBox、MGTableBoxStyled、MGScrollView、MGButton、MGEvents、MGEasyFrame、MGLine等,其中MGBox還支持screenshot方法用於截圖。

GitHub:https://github.com/jverkoey/nimbus

著名的框架,提供了一套非常豐富的UI組件,可以使開發變得更加簡單、有效率。

GitHub:https://github.com/Grouper/FlatUIKit

扁平化設計的UI組件,類似於WP或者iOS7的風格。

GitHub:https://github.com/muccy/MUKMediaGallery

媒體庫效果,支持圖片、視頻及音頻。

PTShowcaseViewController

GitHub:https://github.com/exalted/PTShowcaseViewController

同樣是一個媒體庫效果,支持的格式更多,包括:圖片、視頻、PDF等.

GitHub:https://github.com/mwaterfall/MWPhotoBrowser

圖片展示效果,支持本地及遠程的圖片,使用也比較簡單,只要實現MWPhotoBrowserDelegate協議:

@interface TestViewController ()<MWPhotoBrowserDelegate>{    NSArray *_photos;}-(void) doAction {        NSMutableArray *photos = [[NSMutableArray alloc] init];        for (...) {            MWPhoto* photo = [MWPhoto photoWithURL:[NSURL URLWithString:url]]; // 設置圖片地址            photo.caption = description; // 設置描述            [photos addObject:photo];        }        _photos = photos;        MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];        browser.displayActionButton = YES;                UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];        nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;        [self presentModalViewController:nc animated:YES];}#pragma mark - MWPhotoBrowserDelegate- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {    return _photos.count;}- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {    if (index < _photos.count)        return [_photos objectAtIndex:index];    return nil;}

ios-image-filters

GitHub:https://github.com/esilverberg/ios-image-filters

提供多種圖片濾鏡效果。

PDF Reader Core for iOS

GitHub:https://github.com/vfr/Reader

PDF閱讀器核心。

GitHub:https://github.com/Cocoanetics/DTCoreText

支持富文本的顯示如HTML。

GitHub:https://github.com/FuerteInternational/FTCoreText

富文本視圖

GitHub:https://github.com/akosma/CoreTextWrapper

支持多列的文本視圖

GitHub:https://github.com/nicklockwood/Base64

提供對字符串的Base64編碼

GitHub:https://github.com/rnapier/RNCryptor

提供AES加密方法

來自社區會員li_zhi0123的分享:
會員博客:
http://blog.csdn.net/wstarx/article/details/6317779
http://iosdeveloper.diandian.com/post/2011-05-21/932272

開發幾個常用的開源類庫及下載地址:
1.jsonjson編碼解碼
2.GTMBase64 base64編碼解碼
3.TouchXML解析
4.SFHFKeychainUtils 安全保存用戶密碼到keychain中
5.MBProgressHUD很棒的一個加載等待特效框架
6.ASIHTTPRequest等相關協議封裝
7.EGORefreshTableHeaderView下拉刷新代碼
8.AsyncImageView異步加載圖片並緩存代碼
9.類似setting的豎立也分欄程序
10.MBProgressHUD——進展指示符庫
11.Flurry——詳盡的使用統計
12.CorePlot——2D圖形繪圖儀
13.GData client——iPhone上所有Google相關服務的類庫
14.SDWebImage——簡化網絡圖片處理
15.RegexKitLite——正則表達式支持

可能會用到的庫:
1.exif:svn checkouthttp://iphone-exif.google.code.com/svn/trunk/ iphone-exif
2.圖像處理:svn checkouthttp://simple-iphone-image-processing.googlecode.com/svn/trunk/ simple-iphone-image-processing-read-only


AppStore軟件排名相關,工欲善其事,必先利其器。
1.下載排名相關:appannie
2.用戶行為分析:flurry
3.majicrank-各國排名查詢工具 (推薦)
4.AppViz-App銷售統計軟件 (推薦)
5.PodViz-用戶評論等查看工具
6.appfigures-報表統計分析工具

開發幾個常用的開源類庫及下載地址:引用1.json json編碼解碼2.GTMBase64 base64編碼解碼3.TouchXML xml解析4.SFHFKeychainUtils 安全保存用戶密碼到keychain中5.MBProgressHUD 很棒的一個加載等待特效框架6.ASIHTTPRequest http等相關協議封裝7.EGORefreshTableHeaderView 下拉刷新代碼8.AsyncImageView 異步加載圖片並緩存代碼9.類似setting的豎立也分欄程序

掃描wifi信息:
http://code.google.com/p/uwecaugmentedrealityproject/
http://code.google.com/p/iphone-wireless/

條形碼掃描:http://zbar.sourceforge.net/iphone/sdkdoc/install.html

tcp/ip的通訊協議:http://code.google.com/p/cocoaasyncsocket/

voip/sip:
http://code.google.com/p/siphon/
http://code.google.com/p/asterisk-voicemail-for-iphone/
http://code.google.com/p/voiphone/

three20:https://github.com/facebook/three20

google gdata:http://code.google.com/p/gdata-objectivec-client/

720全景顯示panoramagl:http://code.google.com/p/panoramagl/

jabber client:http://code.google.com/p/ichabber/

PLBlocks:http://code.google.com/p/plblocks/

image processing
http://code.google.com/p/simple-iphone-image-processing/

json編碼解碼:http://code.google.com/p/json-framework

base64編碼解碼:http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/?r=87

xml解析:https://github.com/schwa/TouchXML

安全保存用戶密碼到keychain中:https://github.com/ldandersen/scifihifi-iphone

加載等待特效框架(private api):https://github.com/jdg/MBProgressHUD

http等相關協議封裝:http://allseeing-i.com/ASIHTTPRequest

下拉刷新代碼:https://github.com/enormego/EGOTableViewPullRefresh

異步加載圖片並緩存代碼:http://www.markj.net/iphone-asynchronous-table-image/

iphone TTS:https://bitbucket.org/sfoster/iphone-tts

iphone cook book 源碼:https://github.com/erica/iphone-3.0-cookbook-
iphone 正則表達式:http://regexkit.sourceforge.net/RegexKitLite/

OAuth認證:http://code.google.com/p/oauth/
http://code.google.com/p/oauthconsumer/

原帖地址:http://www.cocoachina.com/bbs/read.php?tid=131431

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved