1 改变状态栏(手机屏幕最上面的状态栏,电池时间那个栏目)
/** modify status bar */
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
2 增加蒙板的写法
/** 大图*/
- (IBAction)bigImage {
//增加蒙板
//将图片移动到视图的顶层
//计算图片的目标位置,动画显示
UIButton *button = [[UIButton alloc]initWithFrame:self.view.bounds];
button.alpha = 0.5f;
button.backgroundColor = [UIColor blackColor];
[self.view addSubview:button];
//将视图拿到顶层
[self.view bringSubviewToFront:self.iconView];
//先计算目标位置
CGFloat viewW = self.view.bounds.size.width;
CGFloat imageW = viewW;
CGFloat imageH = imageW;
CGFloat imageY = (self.view.bounds.size.height-imageH)*0.5;
// [UIView beginAnimations:nil context:nil];
// [UIView setAnimationDuration:2.0f];
// self.iconView.frame = CGRectMake(0, imageY, imageW, imageH);
// [UIView commitAnimations];
[UIView animateWithDuration:1.0f animations:^{
self.iconView.frame = CGRectMake(0, imageY, imageW, imageH);
} completion:^(BOOL finished) {
//
}];
}
3 拦截首尾式动画结束的方法
-(void)smallImage{
//动画变小
// [UIView animateWithDuration:1.0f animations:^{
// self.iconView.frame = CGRectMake(85, 135, 150, 150);
//
// } completion:^(BOOL finished) {
// [self.cover removeFromSuperview];
// }];
//拦截首尾式动画结束的方法
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeCover)];
self.iconView.frame = CGRectMake(85, 135, 150, 150);
[UIView commitAnimations];
//隐藏遮罩
}
-(void)removeCover{
[self.cover removeFromSuperview];
}
4 自定义代码块
将需要自定义的代码块选中,拉进右下角的{}库里面,选中edit,
然后将需要的变量改为 : <#bianliang#>
5 字典转模型
//
// QuestionObject.h
// GuessPicture
//
// Created by xin on 15-3-23.
// Copyright (c) 2015年 Jackey. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface QuestionObject : NSObject
@property (nonatomic,copy) NSString *answer;
@property (nonatomic,copy) NSString *title;
@property (nonatomic,copy) NSString *icon;
@property (nonatomic,strong) NSArray *options;
-(instancetype)initWithDict:(NSDictionary *)dict;
+(instancetype)QuestionWith:(NSDictionary *)dict;
@end
//--------------------------------------------------------------
//
// QuestionObject.m
// GuessPicture
//
// Created by xin on 15-3-23.
// Copyright (c) 2015年 Jackey. All rights reserved.
//
#import "QuestionObject.h"
@implementation QuestionObject
-(instancetype)initWithDict:(NSDictionary *)dict
{
self = [super init];
if (self) {
self.answer = dict[@"answer"];
self.icon = dict[@"icon"];
self.title = dict[@"title"];
self.options = dict[@"options"];
}
return self;
}
+(instancetype)QuestionWith:(NSDictionary *)dict{
return [[self alloc]initWithDict:dict];
}
@end
加载到controller
1 导入
#import "QuestionObject.h"
2 声明变量
@property (nonatomic,strong) NSArray *questions;
3 懒加载
-(NSArray *)questions{
if(!_questions){
NSArray *array = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"questions.plist" ofType:nil]];
NSMutableArray *arrayM =[NSMutableArray array];
for(NSDictionary *dict in array){
//QuestionObject *questionObject = ;
[arrayM addObject:[QuestionObject QuestionWith:dict]];
}
_questions = arrayM;
}
return _questions;
}
4 加载
-(void)viewDidLoad{
[super viewDidLoad];
[self questions];
}