1、将六位的颜色码转换成红绿蓝三色
+ (UIColor *)getColor:(NSString *)hexColor
{
unsigned int red,green,blue;
NSRange range;
range.length = 2;
range.location = 0;
[[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];
range.location = 2;
[[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];
range.location = 4;
[[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];
return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green / 255.0f) blue:(float)(blue / 255.0f) alpha:1.0f];
}
2、计算根据字符串长度计算空间的size
NSString *title =@“苦涩奉公克己恶毒啦没考虑到呢离开电脑矿务局恩看到今年份渴望能看见你哭呢”;
CGSize sizeh =[title boundingRectWithSize:CGSizeMake(_baseContent.frame.size.width-65, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontsizeSmall]} context:nil].size;
(如果要高度或者宽度时,CGSize 改为CGfloat 并且在最后size后面加上 .height 或者 .width)
3、清空归档数据
//归档文件地址
NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSFileManager *manager = [NSFileManager defaultManager];
NSError *error;
[manager removeItemAtPath:filePath error:&error];
4、通知传值
//发出通知 并将courseware的值“季节”传出去
[[NSNotificationCenter defaultCenter]postNotificationName:@"select" object:nil userInfo:@{@"coursewareType":@“季节”}];
//接受通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(click:) name:@"select" object:nil];
//读取传递得值
-(void)click:(NSNotification*)fee{
NSDictionary *dic=[fee userInfo];
NSString *et=dic[@"coursewareType"]
}
5、动画
[UIView animateWithDuration:0.5 animations:^{
动作
}];
如果想让一个动作有动画效果就将代码写入其中,0.5是动画的完成的时间
6、添加子控制器
UIViewController *child = [[MeunViewController alloc]init];
[self addChildViewController:child];
UIView *meune=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, SCREENHEIGHT)];
[[child view] setFrame:meune.frame];
[meune addSubview:child.view];
[self.view addSubview:meune];
[self.view addSubview:bgView];