一款正式的软件 发过 应该具备新特性
我们可以通过设置新特性让用户了解到我们软件的一些新特性
下面简单来实现一下供大家参考
#warning 没有设置代理 ->_->
#import "QHNewfeatureViewController.h"
#define QHNewfeatureCount 4
@interface QHNewfeatureViewController ()<UIScrollViewDelegate>
@property(nonatomic,weak)UIPageControl *pageControl;
@end
@implementation QHNewfeatureViewController
- (void)viewDidLoad {
[super viewDidLoad];
//1.创建一个scrollView
UIScrollView *scrollView = [[UIScrollView alloc]init];
scrollView.frame = self.view.bounds;
scrollView.delegate = self;
[self.view addSubview:scrollView];
CGFloat scrollW = scrollView.width;
CGFloat scrollH = scrollView.height;
//2.添加图片到scrollView
for (int i = 0; i < QHNewfeatureCount; i++) {
UIImageView *imageView = [[UIImageView alloc]init];
imageView.width = scrollW;
imageView.height = scrollH;
imageView.y = 0;
imageView.x = i *imageView.width;
//显示图片
NSString *name = [NSString stringWithFormat:@"new_feature_%d",i+1];
imageView.image = [UIImage imageNamed:name];
[scrollView addSubview:imageView];
}
//3.设置scrollView的其他属性
//如果想要某个方向不能滚动 那么那个方向对应的储存数值传0
scrollView.contentSize = CGSizeMake(QHNewfeatureCount *scrollView.width, 0);
//取出弹簧效果
scrollView.bounces = NO;
scrollView.pagingEnabled = YES;
scrollView.showsHorizontalScrollIndicator = NO;
//4.设置pageControll
UIPageControl *pageControl = [[UIPageControl alloc]init];
pageControl.numberOfPages = QHNewfeatureCount;
//@property(nonatomic,retain) UIColor *pageIndicatorTintColor NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
//@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor
pageControl.currentPageIndicatorTintColor =[UIColor colorWithRed:0.98f green:0.38f blue:0.11f alpha:1.00f];
pageControl.pageIndicatorTintColor =[UIColor colorWithRed:0.74f green:0.74f blue:0.74f alpha:1.00f];
pageControl.centerX = scrollView.width *0.5;
pageControl.centerY = scrollView.height - 50;
[self.view addSubview:pageControl];
self.pageControl = pageControl;
// 不用设置尺寸也可以显示
// pageControl.width = 100;
// pageControl.height = 50;
// pageControl.userInteractionEnabled = NO;
/**
*[UIColor colorWithRed:0.98f green:0.38f blue:0.11f alpha:1.00f];橙色
*[UIColor colorWithRed:0.74f green:0.74f blue:0.74f alpha:1.00f];灰色
*/
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// int page = scrollView.contentOffset.x/scrollView.width;
// self.pageControl.currentPage = page;
// QHLog(@"%ld",(long)self.pageControl.currentPage);
double page = scrollView.contentOffset.x/scrollView.width;
self.pageControl.currentPage = (int)(page + 0.5);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end