- ( void )setupLastImageView:(UIImageView *)imageView
{
// 0.让imageView能跟用户交互
imageView.userInteractionEnabled = YES ;
// 1.添加开始按钮
UIButton *startButton = [[UIButton alloc] init];
[startButton setBackgroundImage:[UIImage imageWithName:@ "new_feature_finish_button" ] forState:UIControlStateNormal];
[startButton setBackgroundImage:[UIImage imageWithName:@ "new_feature_finish_button_highlighted" ] forState:UIControlStateHighlighted];
// 2.设置frame
CGFloat centerX = imageView.frame.size.width * 0.5;
CGFloat centerY = imageView.frame.size.height * 0.6;
startButton.center = CGPointMake(centerX, centerY);
startButton.bounds = (CGRect){CGPointZero, startButton.currentBackgroundImage.size};
// 3.设置文字
[startButton setTitle:@ "开始使用"
forState:UIControlStateNormal];
[startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[startButton addTarget: self
action: @selector (start) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:startButton];
// 4.添加checkbox
UIButton *checkbox = [[UIButton alloc] init];
checkbox.selected = YES ;
[checkbox setTitle:@ "分享给大家"
forState:UIControlStateNormal];
[checkbox setImage:[UIImage imageWithName:@ "new_feature_share_false" ] forState:UIControlStateNormal];
[checkbox setImage:[UIImage imageWithName:@ "new_feature_share_true" ] forState:UIControlStateSelected];
checkbox.bounds = CGRectMake(0, 0, 200, 50);
CGFloat checkboxCenterX = centerX;
CGFloat checkboxCenterY = imageView.frame.size.height * 0.5;
checkbox.center = CGPointMake(checkboxCenterX, checkboxCenterY);
[checkbox setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
checkbox.titleLabel.font = [UIFont systemFontOfSize:15];
[checkbox addTarget: self
action: @selector (checkboxClick:) forControlEvents:UIControlEventTouchUpInside];
checkbox.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10);
[imageView addSubview:checkbox];
}
④点击开始使用时候,切换根控制器
- ( void )start
{
// 显示状态栏
[UIApplication sharedApplication].statusBarHidden = NO ;
// 切换窗口的根控制器
self .view.window.rootViewController = [[IWTabBarViewController alloc] init];
}
|