几点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里面要生成二维码,需要借助一个 ...
随机推荐
- HBase0.94.2-cdh4.2.0需求评估测试报告1.0之四
第二组:文件存储读过程记录 第一组:一个列,四个分区,随机ID 测试列和分区 测试程序或命令 导入文件大小(Mb) 导入文件个数(个) 是否触发flush事件(布尔) 是否触发compact事件(布尔 ...
- #2 create and populate a database && realistic and practical applications
The Chapter3 & Chapter4 of this book tells you how to create a realistic app on the web through ...
- poj:1985:Cow Marathon(求树的直径)
Cow Marathon Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 5496 Accepted: 2685 Case ...
- python基础学习笔记——单继承
1.为什么要有类的继承性?(继承性的好处)继承性的好处:①减少了代码的冗余,提供了代码的复用性②提高了程序的扩展性 ③(类与类之间产生了联系)为多态的使用提供了前提2.类继承性的格式:单继承和多继承# ...
- STL学习笔记1--vector
C++STL(Standard Template Library)标准模板库是通用类模板和算法的集合.包含一些标准的数据结构的实现如queues(队列),lists(链表),stacks(栈)等.ST ...
- css各属性浏览器的兼容情况
- LiveScript 函数
The LiveScript Book The LiveScript Book 函数 定义函数是非常轻量级的. 1.(x, y) -> x + y2.3.-> # an empty ...
- [python学习篇][廖雪峰][1]高级特性 ---迭代
由于字符串也是可迭代对象,因此,也可以作用于for循环: >>> for ch in 'ABC': ... print ch ... A B C 所以,当我们使用for循环时,只要作 ...
- 简单使用jstl实现敏感字替换
package com.ceshi; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; ...
- java反射的基本使用
反射机制是java中非常重要的功能,熟练使用反射功能对实际的开发有很大的帮助. 一,通过反射获取对象实例 使用的对象User package whroid.java.reflect; public c ...