寫iOS 程序的時候往往需要很多第三方框架的支持,可以大大減少工作量,講重點放在軟件本身的邏輯實現(xiàn)上。
GitHub 里面有大量優(yōu)秀的第三方框架,而且 License 對商業(yè)很友好。一下摘錄一下幾乎每個項目都想集成的幾個框架。
SDWebImageView
1. Mantle
Mantle 讓我們能簡化 Cocoa 和 Cocoa Touch 應(yīng)用的 model 層。簡單點說,程序中經(jīng)常要進(jìn)行網(wǎng)絡(luò)請求,請求到得一般是 json 字符串,我們一般會建一個 Model 類來存放這些數(shù)據(jù)。這就要求我們編寫一系列的序列化代碼,來把 json 轉(zhuǎn)換為 Model 。這很費時間,容易錯,不容易修改。 Mantle 很好的解決了這個問題,而且更易用。
GitHub :?https://github.com/Mantle/Mantle
參考:
CocoaPod 集成: pod 'Mantle', '~> 1.5.4'
2. Masonry
IB 時代,如果你還在用代碼絕對布局就太 low 了。隨著蘋果發(fā)布 iPhone6 、 iPhone 6 plus 。 iOS 設(shè)備將會出現(xiàn)越來越豐富的屏幕尺寸,我們不可能根據(jù)每個尺寸做一套布局。所以,使用 autolayout 就很有必要了。在 storyboard 中,可以非常方便的使用 autolayout ,但是為了更好的協(xié)作開發(fā),有些公司依然在手寫布局,令人沮喪的是蘋果提供的 autolayout 語法晦澀難懂,非常影響效率(你可以在?這里?動態(tài)查看 autolayout 的語法)。 Masonry 就是設(shè)計來解決復(fù)雜的手寫 autolayout 。如何優(yōu)雅的使用 autolayout ,且看 Masonry 。
GitHub :?https://github.com/Masonry/Masonry
參考:使用方法,請看 README
CocoaPod 集成: pod 'Masonry', '~> 0.6.1'
3. Reachability
移動互聯(lián)網(wǎng)時代,應(yīng)該很少有應(yīng)用是不需要網(wǎng)絡(luò)連接的吧。監(jiān)測網(wǎng)絡(luò)連接狀態(tài)幾乎是必不可少的一部分。 Reachability 可以完美的完成這一任務(wù)
GitHub :?https://github.com/tonymillion/Reachability
參考:使用方法非常簡單,請看 README
CocoaPod 集成: pod 'Reachability', '~> 3.2'
4. BlocksKit
BlocksKit絕對是 Objective-C 的知心伴侶,它為 OC 常用類提供了強(qiáng)大的 Block 語法支持,使得編寫 OC 代碼變得舒適、快速、優(yōu)雅。反正我是絕對離不開它。
GitHub :?https://github.com/zwaldowski/BlocksKit
參考:?block 使用小結(jié)、在 arc 中使用 block 、如何防止循環(huán)引用 (zz)
CocoaPod 集成: pod 'BlocksKit', '~> 2.2.5'
5. KVOController
如果你在項目中有使用 KVO ,那么 KVOController 絕對是個好選擇。它是 facebook 開源的一個 KVO 增強(qiáng)框架。有以下幾個特性:
使用 Blocks 、自定義 Actions 或者 NSKeyValueObserving 回調(diào)進(jìn)行通知 .
觀測者移除時無異常
控制器 dealloc 時隱式的觀測者移除
提升使用 NSKeyValueObservingInitial 的性能
線程安全并提供在觀測者恢復(fù)時額外的保護(hù)
還有什么理由不使用 KVOController 呢?
GitHub :?https://github.com/facebook/KVOController
參考:?KVOController : facebook 開源的 KVO ( Key-value Observing )工具
CocoaPod : pod 'KVOController', '~> 1.0.3'
6. MBProgressHUD
一個老牌、經(jīng)典的通知組件,如果你們美工沒有專門設(shè)計等待和通知視圖,那就用它吧!
GitHub :?https://github.com/jdg/MBProgressHUD
參考
CocoaPod : pod 'MBProgressHUD', '~> 0.9'
7. ODRefreshControl
很多公司都自己設(shè)計下拉刷新視圖,比如網(wǎng)易新聞 iOS 客戶端,下拉的時候會有廣告出現(xiàn)。如果你只是需要一個下拉刷新,那么可以考慮 ODRefreshControl ,它是原 iOS6 上的橡皮糖刷新樣式,很有意思?,F(xiàn)在也很多大的 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下網(wǎng)絡(luò)請求庫。
GitHub :?https://github.com/AFNetworking/AFNetworking
參考
CocoaPod : pod 'AFNetworking', '~> 2.5.0'
SVProgressHUD 提示效果
GitHub:https://github.com/samvermette/SVProgressHUD
SVProgressHUD和MBProgressHUD效果差不多,不過不需要使用協(xié)議,同時也不需要聲明實例。
直接通過類方法進(jìn)行調(diào)用即可:
1[SVProgressHUD?method]
可以使用以下方法來顯示狀態(tài):
1+?(void)show;+?(void)showWithMaskType:(SVProgressHUDMaskType)maskType;+?(void)showWithStatus:(NSString*)string;+?(void)showWithStatus:(NSString*)string?maskType:(SVProgressHUDMaskType)maskType;
如果需要明確的進(jìn)度,則使用以下方法:
1+?(void)showProgress:(CGFloat)progress;+?(void)showProgress:(CGFloat)progress?status:(NSString*)status;+?(void)showProgress:(CGFloat)progress?status:(NSString*)status?maskType:(SVProgressHUDMaskType)maskType;
通過dismiss方法來隱藏提示:
1+?(void)dismiss;
另外提供了以下方法用于顯示狀態(tài),并在1秒后自動隱藏提示(使用的圖標(biāo)來源于Glyphish:http://www.glyphish.com/):
1+?(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),成功、失敗的狀態(tài)圖標(biāo)來源于Pictos(http://pictos.cc/)。
顯示加載狀態(tài):
1[ZAActivityBar?showWithStatus:@"加載中..."];
顯示成功、失敗狀態(tài):
1[ZAActivityBar?showSuccessWithStatus:@"成功!"];[ZAActivityBar?showErrorWithStatus:@"失敗!"];
隱藏提示:
1[ZAActivityBar?dismiss];
GitHub:https://github.com/stig/json-framework
UIActivityIndicator-for-SDWebImage 為SDWebImage顯示加載效果
GitHub:https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage
用于為SDWebImage在UIImageView加載圖片時,顯示加載效果(UIActivityIndicatorView實現(xiàn)),它提供以下方法:
1-?(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 調(diào)整圖片大小
GitHub:https://github.com/coryalder/UIImage_Resize
提供多種方法為圖片設(shè)置透明度、圓角、裁剪、調(diào)整大小等:
1-?(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;
更詳細(xì)使用見:http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
ImageCacheResize 異步加載圖片、緩存及調(diào)整大小
GitHub:https://github.com/toptierlabs/ImageCacheResize
整合了SDWebImage和UIImage+Resize的功能,用于圖片的異步加載、緩存、以及下載完成后調(diào)整大小并顯示在UIImageView上。
提供了以下API用于加載圖片以及加載完成后調(diào)整圖片大?。?/p>
1-?(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一樣簡單,如以下官方例子:
1[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,再實現(xiàn)一些方法:
1-?(void)?viewDidLoad{??[superviewDidLoad];?self.title?=?@"STableViewController?Demo";??[self.tableView?setBackgroundColor:[UIColor?lightGrayColor]];?//?需要創(chuàng)建兩個自定義視圖用于顯示"下拉刷新"、"上拉加載更多"?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{??//?下拉刷新視圖顯示狀態(tài)信息??if?(willRefreshOnRelease)????//hv.title.text?=?@"松開后刷新...";??else????//hv.title.text?=?@"下拉刷新...";}-?(BOOL)?refresh{??if?(![super?refresh])????return?NO;????//?下拉刷新加載數(shù)據(jù)??[self?performSelector:@selector(addItemsOnTop)?withObject:nil?afterDelay:2.0];??return?YES;}#pragma?mark?-?Load?More-?(void)?willBeginLoadingMore{??//?上拉加載更多視圖加載動畫}-?(void)?loadMoreCompleted{??[super?loadMoreCompleted];??//?上拉加載更多視圖停止動畫????if?(!self.canLoadMore)?{????//沒有更多數(shù)據(jù)的時候執(zhí)行代碼...??}}-?(BOOL)?loadMore{??if?(![super?loadMore])????return?NO;????//?上拉加載更多數(shù)據(jù)??[self?performSelector:@selector(addItemsOnBottom)?withObject:nil?afterDelay:2.0];??return?YES;}//?-?(void)?addItemsOnTop{??//?加載數(shù)據(jù)...????[self.tableView?reloadData];????//?數(shù)據(jù)加載完成通知上拉視圖??[self?refreshCompleted];}-?(void)?addItemsOnBottom{??//?加載更多數(shù)據(jù)...??[self.tableView?reloadData];????//?通過判斷設(shè)置是否可以加載更多??//self.canLoadMore?=?NO;????//?數(shù)據(jù)加載完成通知下拉視圖??[self?loadMoreCompleted];}
SVPullToRefresh 下拉刷新、上拉加載更多
GitHub:https://github.com/samvermette/SVPullToRefresh
包含SVPullToRefresh + SVInfiniteScrolling為UITableView提供下拉刷新、上拉加載更多功能。
使用起來也相當(dāng)簡單,只要在UITableViewController里實現(xiàn)以下方法:
1-?(void)viewDidLoad?{????[superviewDidLoad];????__weak?SVViewController?*weakSelf?=?self;?//?設(shè)置下拉刷新????[self.tableView?addPullToRefreshWithActionHandler:^{????????[weakSelf?insertRowAtTop];????}];????????????//?設(shè)置上拉加載更多????[self.tableView?addInfiniteScrollingWithActionHandler:^{????????[weakSelf?insertRowAtBottom];????}];}-?(void)viewDidAppear:(BOOL)animated?{????[tableView?triggerPullToRefresh];}-?(void)insertRowAtTop?{????//?獲取數(shù)據(jù)....????????//?停止動畫????[self.tableView.pullToRefreshView?stopAnimating];}-?(void)insertRowAtBottom?{????//?獲取數(shù)據(jù)....????????//?停止動畫????[weakSelf.tableView.infiniteScrollingView?stopAnimating];}
CMPopTipView 提示信息
GitHub:https://github.com/chrismiles/CMPopTipView
CMPopTipView用于在一些視圖上顯示提示信息:
1self.tipView?=?[[CMPopTipView?alloc]?initWithMessage:@"提示消息"];self.tipView.delegate?=?self;[self.tipView?presentPointingAtView:anyButton?inView:self.view?animated:YES];?//?點擊按鈕顯示[self.tipView?presentPointingAtBarButtonItem:barButtonItem?animated:YES];?//?點擊導(dǎo)航欄按鈕顯示?#pragma?mark?CMPopTipViewDelegate?methods-?(void)popTipViewWasDismissedByUser:(CMPopTipView?*)popTipView?{??//?清理資源??self.tipView?=?nil;}
GitHub:https://github.com/vicpenap/PrettyKit
定制了一些UI組件如UITableViewCell、UINavigationBar、UITabBar、UIToolBar等,比系統(tǒng)自帶的更加美觀。
GitHub:https://github.com/sobri909/MGBox2
提供一些定制的UI組件可以更簡單快速的創(chuàng)建表格、網(wǎng)格布局,以及豐富的文本呈現(xiàn),基于block的事件機(jī)制等,包含:MGBox、MGTableBox、MGTableBoxStyled、MGScrollView、MGButton、MGEvents、MGEasyFrame、MGLine等,其中MGBox還支持screenshot方法用于截圖。
GitHub:https://github.com/jverkoey/nimbus
著名的框架,提供了一套非常豐富的UI組件,可以使開發(fā)變得更加簡單、有效率。
GitHub:https://github.com/Grouper/FlatUIKit
扁平化設(shè)計的UI組件,類似于WP或者iOS7的風(fēng)格。
GitHub:https://github.com/muccy/MUKMediaGallery
媒體庫效果,支持圖片、視頻及音頻。
PTShowcaseViewController
GitHub:https://github.com/exalted/PTShowcaseViewController
同樣是一個媒體庫效果,支持的格式更多,包括:圖片、視頻、PDF等.
GitHub:https://github.com/mwaterfall/MWPhotoBrowser
圖片展示效果,支持本地及遠(yuǎn)程的圖片,使用也比較簡單,只要實現(xiàn)MWPhotoBrowserDelegate協(xié)議:
1@interfaceTestViewController?(){?NSArray?*_photos;}-(void)?doAction?{?NSMutableArray?*photos?=?[[NSMutableArray?alloc]?init];?for(...)?{????????????MWPhoto*?photo?=?[MWPhoto?photoWithURL:[NSURL?URLWithString:url]];?//?設(shè)置圖片地址????????????photo.caption?=?description;?//?設(shè)置描述????????????[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
開發(fā)幾個常用的開源類庫及下載地址:
1.jsonjson編碼解碼
2.GTMBase64?base64編碼解碼
3.TouchXML?解析
4.SFHFKeychainUtils?安全保存用戶密碼到keychain中
5.MBProgressHUD很棒的一個加載等待特效框架
6.ASIHTTPRequest?等相關(guān)協(xié)議封裝
7.EGORefreshTableHeaderView?下拉刷新代碼
8.AsyncImageView?異步加載圖片并緩存代碼
10.MBProgressHUD——進(jìn)展指示符庫
11.Flurry——詳盡的使用統(tǒng)計
12.CorePlot——2D圖形繪圖儀
13.GData client——iPhone上所有Google相關(guān)服務(wù)的類庫
14.SDWebImage——簡化網(wǎng)絡(luò)圖片處理
15.RegexKitLite——正則表達(dá)式支持
可能會用到的庫:
1.exif:svn checkout?http://iphone-exif.google.code.com/svn/trunk/ iphone-exif
2.圖像處理:svn checkout?http://simple-iphone-image-processing.googlecode.com/svn/trunk/ simple-iphone-image-processing-read-only
AppStore軟件排名相關(guān),工欲善其事,必先利其器。
1.下載排名相關(guān):appannie
2.用戶行為分析:flurry
3.majicrank-各國排名查詢工具 (推薦)
4.AppViz-App銷售統(tǒng)計軟件 (推薦)
5.PodViz-用戶評論等查看工具
6.appfigures-報表統(tǒng)計分析工具
開發(fā)幾個常用的開源類庫及下載地址:引用1.json json編碼解碼2.GTMBase64 base64編碼解碼3.TouchXML xml解析4.SFHFKeychainUtils 安全保存用戶密碼到keychain中5.MBProgressHUD 很棒的一個加載等待特效框架6.ASIHTTPRequest http等相關(guān)協(xié)議封裝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的通訊協(xié)議: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等相關(guān)協(xié)議封裝: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 正則表達(dá)式:http://regexkit.sourceforge.net/RegexKitLite/
OAuth認(rèn)證:?http://code.google.com/p/oauth/
http://code.google.com/p/oauthconsumer/
轉(zhuǎn)載傳送門:http://www.cocoachina.com/ios/20180418/23063.html