几点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];
- }
几点iOS开发技巧的更多相关文章
- iOS开发技巧系列---详解KVC(我告诉你KVC的一切)
KVC(Key-value coding)键值编码,单看这个名字可能不太好理解.其实翻译一下就很简单了,就是指iOS的开发中,可以允许开发者通过Key名直接访问对象的属性,或者给对象的属性赋值.而不需 ...
- 【转】几点 iOS 开发技巧
[译] 几点 iOS 开发技巧 原文:iOS Programming Architecture and Design Guidelines 原文来自破船的分享 原文作者是开发界中知晓度相当高的 Mug ...
- iOS开发技巧
一.寻找最近公共View 我们将一个路径中的所有点先放进 NSSet 中.因为 NSSet 的内部实现是一个 hash 表,所以查找元素的时间复杂度变成了 O(1),我们一共有 N 个节点,所以总时间 ...
- iOS开发技巧系列---使用链式编程和Block来实现UIAlertView
UIAlertView是iOS开发过程中最常用的控件之一,是提醒用户做出选择最主要的工具.在iOS8及后来的系统中,苹果更推荐使用UIAlertController来代替UIAlertView.所以本 ...
- iOS开发技巧 -- 复用代码片段
如果你是一位开发人员在开发过程中会发现有些代码无论是在同一个工程中还是在不同工程中使用率会很高,有经验的人会直接封装在一个类里,或者写成一个宏定义或者把这些代码收集起来,下次直接使用,或者放到xcod ...
- iOS开发技巧 - Size Class与iOS 8多屏幕适配(一)
0. 背景: 在iOS开发中,Auto Layout(自动布局)能解决大部分的屏幕适配问题. 但是当iPhone 6和iPhone 6 Plus发布以后, Auto Layout已经不能解决复杂的屏幕 ...
- iOS 开发技巧收藏贴 链接整理
54个技巧 57个技巧 正则表达式
- iOS开发技巧-2
1,打印View所有子视图 po [[self view]recursiveDescription] 2,layoutSubviews调用的调用时机 * 当视图第一次显示的时候会被调用 * 当这个视图 ...
- IOS开发技巧快速生成二维码
随着移动互联网的发展,二维码应用非常普遍,各大商场,饭店,水果店 基本都有二维码的身影,那么ios中怎么生成二维码呢? 下面的的程序演示了快速生成二维码的方法: 在ios里面要生成二维码,需要借助一个 ...
随机推荐
- selenium2通过linkText/partialLinkText定位元素
通过linkText定位 linkText是根据链接的文本来定位,如下图,导航上全是链接 此时我想找“新闻”这个元素,那么我就可以使用linkText方式定位,语法: By.linkText(“新闻” ...
- HDU 2852 KiKi's K-Number 主席树
题意: 要求维护一个数据结构,支持下面三种操作: \(0 \, e\):插入一个值为\(e\)的元素 \(1 \, e\):删除一个值为\(e\)的元素 \(2 \, a \, k\):查询比\(a\ ...
- 基于百度OCR的图片文字识别
先上图,有图有真相 首先在百度开通ORC服务,目前是免费的,普通识别每天50000次免费,非常棒! 百度文档:http://ai.baidu.com/docs#/OCR-API/top 下载百度SDK ...
- DB2 和 有道词典冲突: A communication error has been detected. Communication protocol being used: Reply.fill().
我在本机安装了DB2 9.5. 使用java jdbc连接,一直没有问题. QC for db2 连接 也一直没有问题. 突然有一天 Java程序连接 报错: A communication erro ...
- TOJ1840: Jack Straws 判断两线段相交+并查集
1840: Jack Straws Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByteTotal Submit: 1 ...
- 配置CORS解决跨域调用—反思思考问题的方式
导读:最近都在用一套完整的Java EE的体系做系统,之前都是用spring框架,现在弄这个Java EE,觉得新鲜又刺激.但,由于之前没有过多的研究和使用,在应用的过程中,也出现了不少的问题.累积了 ...
- Linux硬件资源管理与外设设备使用、系统运行机制及用户管理
Linux硬件资源管理 PCI设备 显卡 $>>dmesg |grep -i vga[ 0.000000] Console: colour VG ...
- html 文本标签
文本格式化标签 标签 描述 <b> 定义粗体文本. <big> 定义大号字. <em> 定义着重文字. <i> 定义斜体字. <small> ...
- Spark2.1.0之源码分析——事件总线
阅读提示:阅读本文前,最好先阅读<Spark2.1.0之源码分析——事件总线>.<Spark2.1.0事件总线分析——ListenerBus的继承体系>及<Spark2. ...
- BZOJ 3167 [Heoi2013]Sao ——树形DP
BZOJ4824的强化版. 改变枚举的方案,使用前缀和进行DP优化. 然后复杂度就是$O(n^2)$了. #include <map> #include <cmath> #in ...