实现图片的滚动,并且自动停止在每张图片上
 
 
- (void)viewDidLoad
{
    [super viewDidLoad];

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 200)];
    
    for (int i=1; i<=8; ++i) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", i]];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(320*(i-1), 0, 320, 200)];
        imageView.image = image;
        [scrollView addSubview:imageView];
    }
    
    scrollView.bounces = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.pagingEnabled = YES;
    scrollView.contentSize = CGSizeMake(320*8, 200);
    [self.view addSubview:scrollView];
    
    
    // Do any additional setup after loading the view.
}

 
 
将图片猩猩假如scrollView 中
 
- (void)viewDidLoad
{
    [super viewDidLoad];
     UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 30, 300, 400)];
     scrollView.backgroundColor = [UIColor orangeColor];
     
     UIImage *image = [UIImage imageNamed:@"1.jpg"];
     UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
     [scrollView addSubview:imageView];
     scrollView.contentSize = CGSizeMake(image.size.width, image.size.height);
     [self.view addSubview:scrollView];
    
    // Do any additional setup after loading the view.
}
 
手势:
 
@interface QFViewController ()<UIGestureRecognizerDelegate]]>
@property (weak, nonatomic) IBOutlet UILabel *myLabel;

@end

@implementation QFViewController{
    CGFloat preScale;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
// 手势
    /*
    UITapGestureRecognizer;//单击
    UIPinchGestureRecognizer;//缩放手势
    UIRotationGestureRecognizer;//旋转手势
    UISwipeGestureRecognizer;//扫动手势(上下左右)
    UIPanGestureRecognizer;//滑动手势
     */
    UIPinchGestureRecognizer *pinchGR=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(onPinch:)];
    [self.myLabel addGestureRecognizer:pinchGR];
    //label、imageview默认不接受人机交互,要手动设置
    self.myLabel.userInteractionEnabled=YES;
    preScale=1;
}
-(void)onPinch:(UIPinchGestureRecognizer *)pGR{
    NSLog(@"%@",pGR);
    NSLog(@"%f",pGR.scale);
    /*
     UIGestureRecognizerStateBegan,
     UIGestureRecognizerStateChanged,
     UIGestureRecognizerStateEnded,
     */
    if (pGR.state==UIGestureRecognizerStateChanged) {
        self.myLabel.font=[UIFont systemFontOfSize:17*preScale*pGR.scale];
    }
    if (pGR.state==UIGestureRecognizerStateEnded) {
        preScale=preScale*pGR.scale;
    }
    
    
}

@end

 

IOS UI 第八篇:基本UI

最新文章

  1. 常用jQuery 方法
  2. bzoj 1305 dance跳舞
  3. $.ajax请求返回数据中status为200,回调的却是error?
  4. C#中委托实现的异步编程
  5. .NET逻辑分层架构总结
  6. 转帖:用五分钟重温委托,匿名方法,Lambda,泛型委托,表达式树
  7. 一个动画 Label (走马观花)
  8. 【读书笔记】读《JavaScript模式》 - 函数复用模式之现代继承模式
  9. CF Destroying Roads (最短路)
  10. IP地址,子网掩码、默认网关,DNS理论解释
  11. 【转】Linux下查看所有用户及用户组
  12. TEA加密算法的文件加密和解密的实现
  13. (asp.net MVC学习)System.Web.Mvc.UrlHelper的学习与使用
  14. 2px边框,4分之1内边框实现选中功能实现
  15. 《C++之那些年踩过的坑(二)》
  16. jmeter监控服务资源
  17. 设计模式之创建类模式PK
  18. create-react-app创建项目并用git上传至GitHub及展示预览效果
  19. Python——hashlib
  20. Unity3d — — UGUI之Box Collider自适应大小

热门文章

  1. 数据库文档生成工具——word2chm,SqlSpec
  2. Android fragment onActivityResult 不起作用
  3. 如何让格斗游戏的横版过关(2) Cocos2d-x 2.0.4
  4. C++ 之 exception
  5. MD5算法的原理与实现
  6. freemarker定义自己的标记(三)-nested说明
  7. List之Distinct()
  8. zabbix-agent TIME_WAIT 过多
  9. redis修改的源代码zincrby,hincrby命令
  10. POJ 3067 Japan 树状数组求逆序对