iOS应用开发中使用UIScrollView控件来实现图片缩放

2020-01-14 17:31:27王振洲

1)@property(nonatomic) BOOL bounces;  设置UIScrollView是否需要弹簧效果

2)@property(nonatomic,getter=isScrollEnabled)BOOLscrollEnabled; 设置UIScrollView是否能滚动

3)@property(nonatomic) BOOL showsHorizontalScrollIndicator; 是否显⽰示⽔水平滚动条

4)@property(nonatomic) BOOL showsVerticalScrollIndicator; 是否显⽰示垂直滚动条

4.注意点

• 如果UIScrollView⽆无法滚动,可能是以下原因:

(1)没有设置contentSize

(2) scrollEnabled = NO

(3) 没有接收到触摸事件:userInteractionEnabled = NO

(4)没有取消autolayout功能(要想scrollView滚动,必须取消autolayout)

 

二、关于UIScrollView常见属性的一些说明

1.属性使用的代码示例

复制代码
#import "MJViewController.h"

 

@interface MJViewController ()
{
    //在私有扩展中创建一个属性
    UIScrollView *_scrollView;
}
@end

 


 

 

复制代码

 

@implementation MJViewController