几点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里面要生成二维码,需要借助一个 ...
随机推荐
- Cacti安装脚本Server端+客户端
#!/bin/bash #auto make install LAMP+Cacti #by authors zhang #RRDtool define path variable R_FILES=rr ...
- JAVA中变量的类型及命名规范
1. 计算机是一种极度精确的机器;2. 要将信息存储在计算机当中,就必须指明信息存储的位置和所需的内存空间;3. 在JAVA编程语言当中,使用声明语句来完成上述的任务; 4. 变量的类型: 5. 变量 ...
- JAVA、JDK等入门概念,下载安装JAVA并配置环境变量
一.概念 Java是一种可以撰写跨平台应用程序的面向对象的程序设计语言,具体介绍可查阅百度JAVA百科,这里不再赘述. Java分为三个体系,分别为: Java SE(J2SE,Java2 Platf ...
- HBase0.94.2-cdh4.2.0需求评估测试报告1.0之三
1.1.1 测试记录 第一组:一个列,一个分区,顺序ID 测试列和分区 测试程序或命令 导入文件大小(Mb) 导入文件个数(个) 是否触发flush事件(布尔) 是否触发compact事件(布尔) 触 ...
- LA 6538 Dinner Coming Soon DP
题意: 给出一个有\(N\)个顶点\(M\)条有向边的图,起点为\(1\),终点为\(N\). 每条边有经过的时间,和经过这条边的花费.一开始你有\(R\)元钱,要在\(T\)时间内赶到终点去约会. ...
- Ubuntu简单指令和热键的学习
Ubuntu查看本机版本的方法 sudo lsb_release -a即可 注销linux: 输入:exit 注意,离开系统不是关机,基本上,linux本身已经有相当多的工作进行,所以你离开时,这次这 ...
- [python 函数学习篇] 关键字参数
函数可以通过 关键字参数 的形式来调用,形如 keyword = value .例如,以下的函数: def parrot(voltage, state='a stiff', action='voom' ...
- Welcome-to-Swift-09类和结构体(Classes and Structures)
类和结构体是人们构建代码所用的一种通用且灵活的构造体.为了在类和结构体中实现各种功能,我们必须要严格按照对于常量,变量以及函数所规定的语法规则来定义属性和添加方法. 与其他编程语言所不同的是,Swif ...
- Bash Command 1: find
GNU find searches the directory tree rooted at each given starting-point by evaluating the given exp ...
- hdu5852 Intersection is not allowed! 【矩阵行列式】
题意 给出\(n*n\)网格\((n<=10^5)\) 顶部有\(K\)个起点,底部有\(K\)个相对应的终点 每次只能向下或向右走 求有多少种从各个起点出发到达对应终点且路径不相交的路径? 对 ...