IOS开发技巧
- @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]; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。