1. 状态栏显示风火轮

//  ViewController.m

//  1.状态栏显示风火轮

//

//  Created by wind on 16/11/13.

//  Copyright © 2016年 wind. All rights reserved.

//

/*

功能:转太烂显示风火轮

作用:执行某个长时间动作时,提示用户耐心等待动作的执行

*/

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@

end

2. 隐藏顶部状态栏

  info.plist种操作,如下:

3. 获取App的当前版本号

4. 列出设备上所有字体

//实际工作中,经常需要调整界面元素的字体种类,本节课将为你输出系统提供的所有字体.

//方便你的检索和使用

//遍历设备中的所有字体

for (NSString *family in [UIFont familyNames]) {

//输出字体组的名称

NSLog(@"**********************%@",family);

//遍历字体组中所有的字体

for (NSString *font in [UIFont fontNamesForFamilyName:family]) {

//输出字体组中字体的名称

NSLog(@"\t----------------------------%@",font);

}

}

5. 对 App进行截屏

//1. 如何截屏 2.存入系统相册

//创建一个颜色对象,使用一张背景图片,作为颜色对象的内容

UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bg.jpeg"]];

//将进行平铺的图案,作为根视图的背景颜色

self.view.backgroundColor = background;

//在图形上下文中,渲染当前窗口根视图的层.

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

//将上下文中的内容,转换成图像对象.

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

//关闭上下文

UIGraphicsEndImageContext();

//保存至系统相册

UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

6. 使用UIApplication打开网页

//使用应用程序单例对象,打开网页的功能

//获取应用程序单例对象,使用它的打开网址功能,打开网页.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];

7. 使用UIApplication拨打电话

//使用应用程序单例对象,拨打电话的功能

//1.创建一个字符串,注意它的前缀

NSString *string = @"tel:18860358995";

//2.转换成网址对象

NSURL *url = [NSURL URLWithString:string];

//3.获取应用程序单例对象,使用它的单例对象,使用它的打开网址功能,调出通信面板,需要真机测试

[[UIApplication sharedApplication] openURL:url];

8. 使用UIApplication发送短信

//使用应用程序单例对象, 发送短信的功能

//1. 创建一个字符串,注意它的前缀

NSString *string = @"sms:18860358995";

//2. 转换成网址对象

NSURL *url = [NSURL URLWithString:string];

[[UIApplication sharedApplication] openURL:url];

9. 邮件功能的使用

//使用应用程序单例对象, 发送邮件功能

NSString *string = @"mailto://tapinfinity@gmail.com";

NSURL *url = [NSURL URLWithString:string];

[[UIApplication sharedApplication] openURL:url];

10. 给方法添加标注

11. 使用XCode的版本管理功能(SCM)

//系统的版本控制功能

//使用版本控制,可以方便地查看代码修改纪录,及恢复为之前的版本.

NSLog(@">>>>>>>>>>>>>>>>>>>>>>>>>>>Test SVN.");

//注:可以在左侧项目蓝,看到某个文件名城的右侧,有个[M]标志,表示该文件已经被编辑,但是尚未被提交 eg:ViewController.m

//1. 选择版本控制选项

//2. 选择提交代码文件选项,将该代码文件,提交给版本控制.

//3. 提交代码前,还需要给这次的版本提交,添加说明文字,作为提交日志以方便日后查看

// 点击提交按钮,提交代码后, 文件名称右侧的[M]标志,已经消失

//修改代码,例:添加一行代码

12. 实现App的Settings设置

13. App图标上显示数字

//给应用程序图标,添加数字角标

[UIApplication sharedApplication].applicationIconBadgeNumber = 3;

14. 检测陀螺仪设备的状态

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

//添加framework:CoreMotion

//功能:负责三种数据,加速度值,陀螺仪值,设备移动值

BOOL isGyroscopeAvailable = [self isGyroscopeAvailable];

NSLog(@">>>>>>>>>>%d",isGyroscopeAvailable);

}

-(BOOL)isGyroscopeAvailable {

//判断系统版本是否为4.0以上

#ifdef __IPHONE_4_0

//初始化管理动作对象

CMMotionManager *motionManager = [[CMMotionManager alloc] init];

//获得陀螺仪设备是否可用

BOOL gyroscopeAvailabel = motionManager.gyroAvailable;

return gyroscopeAvailabel;

//系统版本低于4.0

#else

return NO;

#endif

}

15. 检测定位设备的状态

/*

任何想要获得用户位置信息的应用,都会用到CoreLocation框架.可方便获取设备位置.

*/

//判断设备是否已经开启地理位置的服务

BOOL locationServicesEnabled = [CLLocationManager locationServicesEnabled];

//判断设备是否具备磁力感应,磁力感应可以控制地理位置的精确度

BOOL magnetometerAvailbale = [CLLocationManager headingAvailable];

NSLog(@">>>>>>>>locationServiceEnabled:%d",locationServicesEnabled);

NSLog(@">>>>>>>>locationServiceEnabled:%d",magnetometerAvailbale);

16. 检测前后相机设备的状态

//检测设备的后摄像头是否可用

BOOL cameraAvailable = [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];

//检测设备的前摄像头是否可用

BOOL frontAvailable = [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront];

NSLog(@"后摄像头状态:%d",cameraAvailable);

NSLog(@"前摄像头状态:%d",frontAvailable);

17. 使用Quartz2D绘制基本图形

(1) 自定义QuartzView(继承UIView)

@implementation QuartzVew

// Only override drawRect: if you perform custom drawing.

// An empty implementation adversely affects performance during animation.

- (void)drawRect:(CGRect)rect {

// Drawing code

//重写父类方法

//1. 获得当前视图的上下文

CGContextRef context = UIGraphicsGetCurrentContext();

//2. 在图形上下文中,创建和设置背景填充颜色为黄色.

CGContextSetRGBFillColor(context, 1.0, 1.0, 0.0, 1.0);

//3. 使用黄色填充区域

CGContextFillRect(context, rect);

//4. 创建和设置边框颜色为黑色

CGContextSetRGBStrokeColor(context, 0, 0, 0, 1.0);

//5. 设置画笔的线条粗细

CGContextSetLineWidth(context, 2.0);

//6. 设置矩形的位置及尺寸

CGRect rect2 = CGRectMake(100, 350, 100, 30);

//7. 将矩形边框添加至上下文,作为绘制矩形的准备工作

CGContextAddRect(context, rect2);

//8. 绘制举行边框

CGContextStrokePath(context);

//9. 设置画笔的线条粗细

CGContextSetLineWidth(context, 2.0);

//10. 设置填充颜色

CGContextSetRGBFillColor(context, 1.0, 0.0, 1.0, 1.0);

//11. 创建一个字体对象

UIFont *font = [UIFont boldSystemFontOfSize:31];

NSString *text = @"Hello";

//12. 设置文字的现实位置和尺寸

CGRect rect3 = CGRectMake(100, 120, 100, 30);

//13. 将文字绘制在指定的区域内

[text drawInRect:rect3 withFont:font];

//14. 设置画笔的线条粗细

CGContextSetLineWidth(context, 5.0);

//15. 设置线条样式

CGContextSetLineCap(context, kCGLineCapButt);

//16. 设置边框的颜色

CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);

//17. 创建一个坐标数组

CGPoint points[5];

//18. 设定坐标数组的内容

points[0] = CGPointMake(100, 200);

points[1] = CGPointMake(100, 300);

points[2] = CGPointMake(200, 300);

points[3] = CGPointMake(200, 200);

points[4] = CGPointMake(100, 200);

//19. 将坐标连线置入上下文

CGContextAddLines(context, points, 5);

//20. 执行绘制边框动作

CGContextStrokePath(context);

}

(2) 根视图控制器对应的类ViewDidLoad中:

//设定视图显示区域

CGRect rect = self.view.bounds;

//初始化自定义视图对象

QuartzVew *view = [[QuartzVew alloc] initWithFrame:rect];

//将视图添加至当前窗口的根视图

[self.view addSubview:view];

//////////////////////////////////////////////////////////////////////////

18. App图标名称的国际化

/*

1.点击项目名称,进入项目设置面板

2.切换简体中文

* *实现通过修改多语言环境下的配置文件,实现程序名称的国际化

*/

//////////////////////////////////////////////////////////////////////////

19. App内容文本的国际化

//通过一个宏,查找国际化资源文件中,键值标签所指向的字符串

NSString *str = NSLocalizedString(@"label", @"");

//创建一个标签对象,用老显示获得的字符串

UILabel *label = [[UILabel alloc] init];

label.frame = CGRectMake(130, 100, 250, 60);

label.text = str;

[self.view addSubview:label];

20. 计算两个日期间的差值

//计算日期间的差值

NSDate *dateA = [NSDate date];

NSDate *dateB = [[NSDate alloc] initWithTimeInterval:-60*60*24*1000 sinceDate:[NSDate date]];

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *components = [calendar components:NSYearCalendarUnit | NSMoviesDirectory | NSDayCalendarUnit

fromDate:dateA

toDate:dateB

options:0];

NSLog(@"Different in date components: %i/%i/%i",components.day,components.month,components.year);

21. 正则表达式的使用

//检测邮箱格式的正确性

NSString *str = @"1983457078@gmail.com";

//创建一个正则表达式类,帮助您检测字符串,是否匹配正则表达式.

NSRegularExpression *regexEmail = [NSRegularExpression regularExpressionWithPattern:@"^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$" options:0 error:nil];

//返回第一个匹配的结果

NSTextCheckingResult *isEmail = [regexEmail firstMatchInString:str options:0 range:NSMakeRange(0, [str length])];

//根据结果做相应的处理

if (isEmail) {

UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Perfect!" message:@"It's an email" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];

[alertview show];

}else {

UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Sorry." message:@"It's not an email" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];

[alertview show];

}

22. 本地同志的使用

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

//本地通知,进行应用程序的本地同志

//创建一个本地同志对象

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

NSDate *now = [NSDate date];

//设置在当前时间的2秒后,触发本地通知

localNotification.fireDate = [now dateByAddingTimeInterval:2];

//设置重复次数

localNotification.repeatInterval = 0;

//设置时区:默认

localNotification.timeZone = [NSTimeZone defaultTimeZone];

//设置通知的提醒声音模版.

localNotification.soundName = UILocalNotificationDefaultSoundName;

//设置通知的文本内容

localNotification.alertBody = @"Hi,it's time to make a decision!";

//设置程序图标右上角显示的数字

localNotification.applicationIconBadgeNumber = 1;

//创建一个字典对象,用来传递数据

NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"infoValue"  forKey:@"infoKey"];

localNotification.userInfo = infoDic;

//开始定时执行通知,点击切换至项目代理文件.

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

}

- (void)applicationWillResignActive:(UIApplication *)application {

// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

//将程序右上角的数字减1

application.applicationIconBadgeNumber -= 1;

}

//新建一个代理方法,用来处理客户点击通知后的时间

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"HURRY UP" message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

[alertview show];

//获得传递来的字典对象

NSDictionary *dic = notification.userInfo;

//输出传递的内容

NSLog(@"The value of infoKey:%@",[dic objectForKey:@"infoKey"]);

//将程序图标右上角数字减1

application.applicationIconBadgeNumber -= 1;

}

23. 使用Application Loader发布应用

iOS - 使用进阶的更多相关文章

  1. iOS开发进阶

    <iOS开发进阶>基本信息作者: 唐巧 出版社:电子工业出版社ISBN:9787121247453上架时间:2014-12-26出版日期:2015 年1月开本:16开页码:268版次:1- ...

  2. iOS开发进阶(唐巧)读书笔记(一)

    如何提高iOS开发技能 1.阅读博客:https://github.com/tangqiaoboy/iOSBlogCN 40多位iOS开发博主的博客地址 2.读书:每年阅读一本高质量的iOS开发书籍 ...

  3. [iOS UI进阶 - 6.1] 核心动画CoreAnimation

    A.基本知识 1.概念 Core Animation是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍,使用它需要先添加QuartzCore.framework和引入对 ...

  4. [iOS UI进阶 - 6.0] CALayer

    A.基本知识 1.需要掌握的 CALayer的基本属性 CALayer和UIView的关系 position和anchorPoint的作用   2.概念 在iOS中,你能看得见摸得着的东西基本上都是U ...

  5. [iOS UI进阶 - 3.1] 触摸事件的传递

    A.事件的产生和传递 发生触摸事件后,系统会将该事件加入到一个由UIApplication管理的事件队列中UIApplication会从事件队列中取出最前面的事件,并将事件分发下去以便处理,通常,先发 ...

  6. [iOS UI进阶 - 3.0] 触摸事件的基本处理

    A.需要掌握和练习的 1.介绍事件类型2.通过按钮的事件处理引出view的事件处理3.响应者对象 --> UIResponder --> UIView4.view的拖拽* 实现触摸方法,打 ...

  7. [iOS UI进阶 - 2.3] 彩票Demo v1.3

    A.需求 真机调试 "关于”模块 存储开关状态 打电话.发短信 应用评分 打开其他应用 cell 在iOS6 和 iOS7的适配 block的循环引用 屏幕适配 code source:   ...

  8. [iOS UI进阶 - 2.0] 彩票Demo v1.0

    A.需求 1.模仿“网易彩票”做出有5个导航页面和相应功能的Demo 2.v1.0 版本搭建基本框架   code source:https://github.com/hellovoidworld/H ...

  9. [iOS UI进阶 - 0] Quiartz2D

    A.简介 1. 需要掌握的 drawRect:方法的使用 常见图形的绘制:线条.多边形.圆 绘图状态的设置:文字颜色.线宽等 图形上下文状态的保存与恢复 图形上下文栈 1.基本图形绘制* 线段(线宽. ...

  10. iOS开发进阶-实现多线程的3种方法

    相关文章链接: 1.多线程简介 2.实现多线程的3种方法 ......待续 前言 在多线程简介中,我已经说明过了,为了提高界面的流畅度以及用户体验.我们务必要把耗时的操作放到别的线程中去执行,千万不要 ...

随机推荐

  1. Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力

    A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/p ...

  2. hdu 4493 Tutor 水题

    Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...

  3. PHP对大小写敏感问题的处理比较乱,写代码时可能偶尔出问题,所以这里总结一下。以便用到的出现错误

    推荐大家始终坚持“大小写敏感”,遵循统一的代码规范. 1. 变量名区分大小写 1 <?php 2 $abc = 'abcd'; 3 echo $abc; //输出 'abcd' 4 echo $ ...

  4. POJ 3126 Prime Path (BFS)

    [题目链接]click here~~ [题目大意]给你n,m各自是素数,求由n到m变化的步骤数,规定每一步仅仅能改变个十百千一位的数,且变化得到的每个数也为素数 [解题思路]和poj 3278类似.b ...

  5. cocos2d win7 安卓环境配置开发

    相关工具 下载 Android SDK 下载和安装 Android NDK版本不要选r9的.用r8e!r9会报错 下载安装JDK版本是 jdk-7u13-windows-x64.exe 下载和安装Cy ...

  6. Photoshop-制作图片圆角2种方法[转]

    方案一:       使用选区和蒙版相结合,用图章制作圆角选区,删除多余部分 效果: 实现步骤: 一.如果是直接在已有的图片上面编辑则看下图,否则跳过此不 二.用矩形工具选择需要保留的图片内容 三.选 ...

  7. 用于迭代器的yield return

    在我们写迭代器的时候往往继承自IEnumerable public class Tuple<T1, T2, T3> : Tuple<T1, T2>,IEnumerable { ...

  8. Qt 类外调用一个 private slots 函数

    MainWindow中 private slots 函数 void print_on_log(QString strtemp);输出一个字符串到编辑窗口中 class MainWindow:publi ...

  9. mysql describe

    describe命令一.describe命令用于查看特定表的详细设计信息,例如为了查看guestbook表的设计信息,可用:describe guestbook describe ol_user us ...

  10. PHP|开发必知的良好实践

    过滤.验证.转义 所有这些外部资源都不能完全相信 $_GET $_POST $_REQUEST $_COOKIE $argv php://stdin php://input file_get_cont ...