幾點iOS開發技巧
發佈於:2013-08-27 15:59閱讀數:8636
原文作者是開發界中知曉度相當高的 Mugunth Kumar,他是 MKNetworkKit 的作者(雖然沒有 AFNetworking 使用那麼廣泛,但也是一個很棒的 Network Kit),更是最近流傳甚廣的《iOS 5/6 Programming - Pushing The L
“”- @interface MyAppFeaturedYouTubeVideosViewController : UIViewController
- @interface MyAppFeaturedYouTubeVideosFeaturedViewController : MyAppViewController
- @interface MyAppViewController : UIViewController
- -(UIView*) errorView;
- -(UIView*) loadingView;
- -(void) showLoadingAnimated:(BOOL) animated;
- -(void) hideLoadingViewAnimated:(BOOL) animated;
- -(void) showErrorViewAnimated:(BOOL) animated;
- -(void) hideErrorViewAnimated:(BOOL) animated;
- -(UIView*) errorView {
- return nil;
- }
- -(UIView*) loadingView {
- return nil;
- }
- -(void) showLoadingAnimated:(BOOL) animated {
- UIView *loadingView = [self loadingView];
- loadingView.alpha = 0.0f;
- [self.view addSubview:loadingView];
- [self.view bringSubviewToFront:loadingView];
- double duration = animated ? 0.4f:0.0f;
- [UIView animateWithDuration:duration animations:^{
- loadingView.alpha = 1.0f;
- }];
- }
- -(void) hideLoadingViewAnimated:(BOOL) animated {
- UIView *loadingView = [self loadingView];
- double duration = animated ? 0.4f:0.0f;
- [UIView animateWithDuration:duration animations:^{
- loadingView.alpha = 0.0f;
- } completion:^(BOOL finished) {
- [loadingView removeFromSuperview];
- }];
- }
- -(void) showErrorViewAnimated:(BOOL) animated {
- UIView *errorView = [self errorView];
- errorView.alpha = 0.0f;
- [self.view addSubview:errorView];
- [self.view bringSubviewToFront:errorView];
- double duration = animated ? 0.4f:0.0f;
- [UIView animateWithDuration:duration animations:^{
- errorView.alpha = 1.0f;
- }];
- }
- -(void) hideErrorViewAnimated:(BOOL) animated {
- UIView *errorView = [self errorView];
- double duration = animated ? 0.4f:0.0f;
- [UIView animateWithDuration:duration animations:^{
- errorView.alpha = 0.0f;
- } completion:^(BOOL finished) {
- [errorView removeFromSuperview];
- }];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor appOffWhiteColor]; // changes all my views to "off-white"
- }
- +(UIFont*) appFontOfSize:(CGFloat) pointSize {
- return [UIFont fontWithName:@"MyriadPro-Regular" size:pointSize];
- }
- +(UIFont*) boldAppFontOfSize:(CGFloat) pointSize {
- return [UIFont fontWithName:@"MyriadPro-Black" size:pointSize];
- }
- #define GREY(color) [UIColor colorWithRed:color/255.0 green:color/255.0 blue:color/255.0 alpha:1]
- +(UIColor*) appBackgroundColor {
- return [UIColor colorWithPatternImage:[UIImage imageNamed:@"BGPattern"]];
- }
- +(UIColor*) appBlack1Color {
- return GREY(38);
- }
- +(UIColor*) appOffWhiteColor {
- return GREY(234);
- }
- @implementation AppPrefixLabel
- -(void) setup {
- self.font = [UIFont fontWithName:@"SourceSansPro-Semibold" size:self.font.pointSize];
- self.textColor = [UIColor redColor];
- }
- -(id) initWithFrame:(CGRect)frame {
- if((self = [super initWithFrame:frame])) {
- [self setup];
- }
- return self;
- }
- -(id) initWithCoder:(NSCoder *)aDecoder {
- if((self = [super initWithCoder:aDecoder])) {
- [self setup];
- }
- return self;
- }
- @end
- +(UIFont*) appFontOfSize:(CGFloat) pointSize {
- NSString *currentFontName = [[ThemeProvider sharedInstance] currentFontName];
- return [UIFont fontWithName:currentFontName size:pointSize];
- }
CocoaChina是全球最大的蘋果開發中文社區,官方微信每日定時推送各種精彩的研發教程資源和工具,介紹app推廣營銷經驗,最新企業招聘和外包信息,以及Cocos2d引擎、Cocos Studio開發工具包的最新動態及培訓信息。關注微信可以第一時間瞭解最新產品和服務動態,微信在手,天下我有!