1 模态
//跳转到哪个界面,就给哪个界面设置跳转动画
svc.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:svc animated:YES completion:^{
NSLog(@"跳转完成");
}];
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"返回上一界面");
}];
2 navigationControll
//每个视图控制器中都有一个navigationControll属性
[self.navigationController pushViewController:svc animated:YES];
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController popToViewController:self.navigationController.viewControllers[0] animated:YES];/返回指定的视图控制器
添加导航栏
[self.navigationController setNavigationBarHidden:hidden animated:YES];
3 延时后, 执行选择器方法
[tomView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:count * 0.1];
4 NSTimer
定时器需要在dealloc中设置为无效的,才能自动释放
- (void)dealloc
{
if (timer.isValid) {
//设置为无效的
[timer invalidate];
}
//不写[super dealloc]
}
5 字符集与字符串
#if 0
//invertedSet 取相反的字符集
NSCharacterSet *set = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
NSArray *arr = [string componentsSeparatedByCharactersInSet:set];
NSString *str = [arr componentsJoinedByString:@""];
if ([str isEqualToString:string]) {
return YES;
}else{
return NO;
}
#else
//去除字符串两边包含在字符集中的字符
NSString *str = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
if(str.length > 0){
return NO;
}else{
return YES;
}
str = [str stringByAppendingString:title];字符串拼接
str = [str stringByReplacingCharactersInRange:range withString:string];
6 文字的属性
//设置navigationbar标题的属性
[nc.navigationBar setTitleTextAttributes:@{
NSForegroundColorAttributeName:[UIColor whiteColor],
NSFontAttributeName:[UIFont systemFontOfSize:25]
}];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:97 / 255.0 green:197 / 255.0 blue:6 / 255.0 alpha:1.0]} forState:UIControlStateSelected];
7 图像
UIImage *image = [[UIImage imageNamed:@"itemImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
拉伸图像
UIImage *image = [[UIImage imageNamed:@"Nav_Bg2"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageResizingModeStretch];端盖
8 图层
label.layer.cornerRadius = 20;
label.layer.masksToBounds = YES;
btn.layer.cornerRadius = 50; //设置圆角
btn.layer.borderWidth = 1; //设置边框
btn.layer.borderColor = [UIColor blackColor].CGColor;
9 Plist 解析
- (void)readPlist{
NSString *fileName = [NSString stringWithFormat:@"image_%@", self.photoName];
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];
NSArray *arr = [NSArray arrayWithContentsOfFile:path];
for (NSDictionary *dic in arr) {
[self.imageArr addObject:dic[@"imageName"]];
}
}
//返回指定类型文件的路径,第二个参数为nil,表示应用程序包的顶级路径
NSArray *plistArr = [[NSBundle mainBundle] pathsForResourcesOfType:@"plist" inDirectory:nil];
// NSLog(@"%@", plistArr);
int index = 0;
for (NSString *path in plistArr) {
NSRange range = [path rangeOfString:@"image"];
if (range.location == NSNotFound) {
continue;
}
NSRange range1 = [path rangeOfString:@".plist"];
NSString *title = [path substringWithRange:NSMakeRange(range.location + range.length + 1, range1.location - range.location - range.length - 1)];
// NSLog(@"%@", title);
10 沙盒路径
NSUserDefaults *userData = [NSUserDefaults standardUserDefaults];
//将数据以键值对的形式写入文件
[userData setObject:name forKey:@"UserName"];
[userData setObject:pwd forKey:@"Pwd"];
获取值
NSString *readName = [userData objectForKey:@"UserName"];
//同步到磁盘
[userData synchronize];
NSString *path = NSHomeDirectory();沙盒路径
//得到沙盒路径下的Documents文件夹的路径
NSArray *arr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
传值方式:代理 block代码块 通知 kvo
当doubleTap失败的时候,使用tap
[tap requireGestureRecognizerToFail:doubleTap];
//CGRectInset 以原来对象的中心点为基准,对原对象进行放大或缩小
CGRectInset()
Storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
HomeViewController *homeView = [storyboard instantiateViewControllerWithIdentifier:@"homeID"];
//跳转到哪个界面,就给哪个界面设置跳转动画
svc.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentViewController:svc animated:YES completion:^{
NSLog(@"跳转完成");
}];
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"返回上一界面");
}];
2 navigationControll
//每个视图控制器中都有一个navigationControll属性
[self.navigationController pushViewController:svc animated:YES];
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController popToViewController:self.navigationController.viewControllers[0] animated:YES];/返回指定的视图控制器
添加导航栏
[self.navigationController setNavigationBarHidden:hidden animated:YES];
3 延时后, 执行选择器方法
[tomView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:count * 0.1];
4 NSTimer
定时器需要在dealloc中设置为无效的,才能自动释放
- (void)dealloc
{
if (timer.isValid) {
//设置为无效的
[timer invalidate];
}
//不写[super dealloc]
}
5 字符集与字符串
#if 0
//invertedSet 取相反的字符集
NSCharacterSet *set = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
NSArray *arr = [string componentsSeparatedByCharactersInSet:set];
NSString *str = [arr componentsJoinedByString:@""];
if ([str isEqualToString:string]) {
return YES;
}else{
return NO;
}
#else
//去除字符串两边包含在字符集中的字符
NSString *str = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
if(str.length > 0){
return NO;
}else{
return YES;
}
str = [str stringByAppendingString:title];字符串拼接
str = [str stringByReplacingCharactersInRange:range withString:string];
6 文字的属性
//设置navigationbar标题的属性
[nc.navigationBar setTitleTextAttributes:@{
NSForegroundColorAttributeName:[UIColor whiteColor],
NSFontAttributeName:[UIFont systemFontOfSize:25]
}];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:97 / 255.0 green:197 / 255.0 blue:6 / 255.0 alpha:1.0]} forState:UIControlStateSelected];
7 图像
UIImage *image = [[UIImage imageNamed:@"itemImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
拉伸图像
UIImage *image = [[UIImage imageNamed:@"Nav_Bg2"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10) resizingMode:UIImageResizingModeStretch];端盖
8 图层
label.layer.cornerRadius = 20;
label.layer.masksToBounds = YES;
btn.layer.cornerRadius = 50; //设置圆角
btn.layer.borderWidth = 1; //设置边框
btn.layer.borderColor = [UIColor blackColor].CGColor;
9 Plist 解析
- (void)readPlist{
NSString *fileName = [NSString stringWithFormat:@"image_%@", self.photoName];
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];
NSArray *arr = [NSArray arrayWithContentsOfFile:path];
for (NSDictionary *dic in arr) {
[self.imageArr addObject:dic[@"imageName"]];
}
}
//返回指定类型文件的路径,第二个参数为nil,表示应用程序包的顶级路径
NSArray *plistArr = [[NSBundle mainBundle] pathsForResourcesOfType:@"plist" inDirectory:nil];
// NSLog(@"%@", plistArr);
int index = 0;
for (NSString *path in plistArr) {
NSRange range = [path rangeOfString:@"image"];
if (range.location == NSNotFound) {
continue;
}
NSRange range1 = [path rangeOfString:@".plist"];
NSString *title = [path substringWithRange:NSMakeRange(range.location + range.length + 1, range1.location - range.location - range.length - 1)];
// NSLog(@"%@", title);
10 沙盒路径
NSUserDefaults *userData = [NSUserDefaults standardUserDefaults];
//将数据以键值对的形式写入文件
[userData setObject:name forKey:@"UserName"];
[userData setObject:pwd forKey:@"Pwd"];
获取值
NSString *readName = [userData objectForKey:@"UserName"];
//同步到磁盘
[userData synchronize];
NSString *path = NSHomeDirectory();沙盒路径
//得到沙盒路径下的Documents文件夹的路径
NSArray *arr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
传值方式:代理 block代码块 通知 kvo
当doubleTap失败的时候,使用tap
[tap requireGestureRecognizerToFail:doubleTap];
//CGRectInset 以原来对象的中心点为基准,对原对象进行放大或缩小
CGRectInset()
Storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
HomeViewController *homeView = [storyboard instantiateViewControllerWithIdentifier:@"homeID"];