几点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里面要生成二维码,需要借助一个 ...
随机推荐
- 安装好的IIS,发布成功后打开网站出现错误
开发web项目时需要安装IIS,在安装好IIS的Windows7本上发布asp.net网站时,web程序已经映射到了本地IIS上,但运行如下错误提示“处理程序“PageHandlerFactory ...
- Java线程和多线程(四)——主线程中的异常
作为Java的开发者,在运行程序的时候会碰到主线程抛异常的情况.如果开发者使用Java的IDE比如Eclipse或者Intellij IDEA的话,可能是不需要直接面对这个问提的,因为IDE会处理运行 ...
- CodeForces 567F DP Mausoleum
本着只贴代码不写分析的题解是在耍流氓的原则,还是决定写点分析. 思路很清晰,参考的官方题解,一下文字仅对题解做一个简要翻译. 题意: 有1~n这n个数,每个数用两次.构成一个长为2n的序列,而且要求序 ...
- 02_ThreadLocal语法与源码分析
文章导读: 早在JDK 1.2的版本中就提供Java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路.使用这个工具类可以很简洁地编写出优美的多线程 ...
- CRM知识点汇总(未完💩💩💩💩💩)
一:项目中每个类的作用 StarkSite 对照admin中的AdminSite,相当于一个容器,用来存放类与类之间的关系. 先实例化对象,然后执行该对象的register方法.将注册类添加到_reg ...
- Leetcode 454.四数相加II
四数相加II 给定四个包含整数的数组列表 A , B , C , D ,计算有多少个元组 (i, j, k, l) ,使得 A[i] + B[j] + C[k] + D[l] = 0. 为了使问题简单 ...
- 2017"百度之星"程序设计大赛 - 复赛
Arithmetic of Bomb Accepts: 1050 Submissions: 1762 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- 子元素浮动父容器高度不能自适应的CSS解决方法
百度标题:子元素浮动父容器高度不能自适应的CSS解决方法 从第二份工作开始,已经不怎么写样式了,然后就忘记了一部分,有的也生疏了. 今天碰到子元素意外挤到一起的问题,就问公司前端工程师是怎么回事,F1 ...
- 【Vjudge】P1989Subpalindromes(线段树)
题目链接 水题一道,用线段树维护哈希值,脑补一下加减乱搞搞……注意细节就过了 一定注意细节…… #include<cstdio> #include<cstdlib> #incl ...
- HDU——1005Number Sequence(模版题 二维矩阵快速幂+操作符重载)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...