ios-新浪微博开发-13-新特性(1)

88 篇文章 0 订阅

一款正式的软件 发过 应该具备新特性

我们可以通过设置新特性让用户了解到我们软件的一些新特性

下面简单来实现一下供大家参考

#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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值