UIScrollView的简单使用 以及一些常用属性

scrollView 的简单 属性 以及  使用

//--------------------------------------------------------------------------------


RoootViewController.h 


//--------------------------------------------------------------------------------

#import <UIKit/UIKit.h>

@interface RoootViewController : UIViewController

//定义UIScrollViewui 变量

@property (strong,nonatomic)UIScrollView *scrollview;

@end


//--------------------------------------------------------------------------------





  RoootViewController.m




//--------------------------------------------------------------------------------

#import "RoootViewController.h"

@interface RoootViewController ()

@end

@implementation RoootViewController


- (void)dealloc
{
    [_scrollview release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor greenColor];
    [self createScrollview ];
    
    // Do any additional setup after loading the view.
}

-(void)createScrollview

{
    _scrollview =[[UIScrollView alloc]initWithFrame:self.view.bounds];
    _scrollview.backgroundColor=[UIColor orangeColor];
   
   
 
    [self.view addSubview:_scrollview];
    [self customScrollview];
    
}
-(void)customScrollview
{
    UIImage *image=[UIImage imageNamed:@"car4.jpg"];
    UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
    imageView.image=image;

 

  //image 用的 类方法 当我们这个函数结束的时候会自动的释放一次   如果吧图片加载上imagevie上

    // imageview  会自动保留一次计数 image页 一起消失;

[_scrollview addSubview:imageView];

   

//conentSize  来控制 滚动的范围

_scrollview.contentSize=image.size;

   

//设置超出边界 反弹效果 默认为yes

    _scrollview .bounces=NO;
    
    //活动时候的水平和 垂直方向额滚动条默认 为 YES
    _scrollview .showsHorizontalScrollIndicator=NO;
    _scrollview.showsVerticalScrollIndicator=YES;
    //设置滚动条样式
    /*
     
     UIScrollViewIndicatorStyleDefault,     // black with white border. good against any background
     UIScrollViewIndicatorStyleBlack,       // black only. smaller. good against a white background
     UIScrollViewIndicatorStyleWhite
     */
    _scrollview .indicatorStyle=UIScrollViewIndicatorStyleWhite;
    
    //设置视图的边距
     _scrollview.contentInset=UIEdgeInsetsMake(0, 0, 150, 50);
    //设置滚动条的 边距
    
    _scrollview .scrollIndicatorInsets=UIEdgeInsetsMake(0, 0, 50, 50) ;
    //控制翻页  他滑动的是 滚动视图的宽度和高度
    _scrollview.pagingEnabled=YES;
    //禁止滚动
    //_scrollview.scrollEnabled=NO;
    
    //滚动的速度
    _scrollview.decelerationRate=1;
    //偏移量
    _scrollview.contentOffset=CGPointZero;
    //最da缩放系数
    _scrollview.maximumZoomScale=2;
    //最小缩放系数
    _scrollview.minimumZoomScale=0.2;
    //缩放参数
    _scrollview.zoomScale=3;
    [image release];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

//--------------------------------------------------------------------------------






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值