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. 多个非同源的shared_ptr管理对象引起double free

    有多个不同源的shared_ptr管理对象时会出现多次释放对象,这里不同源是指多组间不是通过拷贝构造.复制等手段而来的,即几组shared_ptr是独立声明的. #include<iostrea ...

  2. kickstart一键自动安装Linux系统

    kickstart,无人值守,自动安装系统.本文介绍kickstart的用法. #安装系统的信息——可以参考 [root@larrywen pdf]# vim ~/anaconda-ks.cfg 第一 ...

  3. MyEclipse7.0破解下载

    MyEclipse7.0 下载地址:downloads.myeclipseide.com/downloads/products/eworkbench/7.0M1/MyEclipse_7.0M1_E3. ...

  4. 区域医疗移动医疗影像解决方案1-基于HTML5的PACS

    系统描述: 1.系统基于HTML5开发,突破了平台限制,可以在任意移动终端的浏览器上调阅原始海量医学影像图像. 2.客户端无需任何下载安装,直接通过浏览器即可使用,并处理基于DICOM标准的高保真医学 ...

  5. 【ZZ】快速學會開發Android App

    http://www.cc.ntu.edu.tw/chinese/epaper/0022/20120920_2209.html 作者:吳玉舒 / 臺灣大學計算機及資訊網路中心程式設計組幹事 智慧型手機 ...

  6. javascript 的位操作符转换推断

    var a = "10" | 0; alert(a); alert (typeof a); 结果为10,number. 这就是说这条语句可以将字符串转化为number. 如果: v ...

  7. 加密数据的填充方式(Padding)

    1.填充数据为填充字节的长度 这种填充方式中,填充字符串由一个字节序列组成,每个字节填充该字节序列的长度.假定块长度为8,原文数据长度9,则填充字节数等于0x07:如果明文数据长度为8的整数倍,则填充 ...

  8. IIS 之 HTTP错误 404.17 - Not Found(请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。)

    问题描述:HTTP 404.17 - Not Found" IIS 7.5 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理 .   出现这种情况的原因通常是因为先安装了Framew ...

  9. 关于c#调用c/c++ dll遇到的问题总结

    前段时间公司做了个winform程序,需要调用c 的dll去读取卡号的程序,期间遇到些问题,下面来分享下 一.dll路径问题 相信很多开发者都会遇到这个问题,我总结了下我现在有3总方式去解决这个问题: ...

  10. 【Shell脚本学习10】Shell运算符:Shell算数运算符、关系运算符、布尔运算符、字符串运算符等

    Bash 支持很多运算符,包括算数运算符.关系运算符.布尔运算符.字符串运算符和文件测试运算符. 原生bash不支持简单的数学运算,但是可以通过其他命令来实现,例如 awk 和 expr,expr 最 ...