zoukankan      html  css  js  c++  java
  • ios开发系列之Swift_UI_ScrollVIew

    //  Created by dongqiangfei on 16/3/17.

    //  Copyright © 2016年 dongqiangfei. All rights reserved.

    //

    import UIKit

    class ViewController: UIViewController, UIScrollViewDelegate{

        var ExampleScorllView : UIScrollView!

        

        override func viewDidLoad() {

            super.viewDidLoad()

            MakeScrollView()

            

            // Do any additional setup after loading the view, typically from a nib.

        }

        

        private func MakeScrollView() {

            self.ExampleScorllView = UIScrollView.init()

            self.ExampleScorllView.frame = CGRectMake(0, 64, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height - 64)

            self.ExampleScorllView.backgroundColor = UIColor.orangeColor()

            self.view .addSubview(self.ExampleScorllView)

            //设置缩放最大最小倍数

            self.ExampleScorllView.minimumZoomScale = 0.3

            self.ExampleScorllView.maximumZoomScale = 3

            self.ExampleScorllView.delegate = self

            self.ExampleScorllView.contentSize = CGSizeMake(UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height*3)

            //设置滑动条的样式

            self.ExampleScorllView.indicatorStyle = UIScrollViewIndicatorStyle.White

            //取消滑动条

            self.ExampleScorllView.showsHorizontalScrollIndicator = true//水平

            self.ExampleScorllView.showsVerticalScrollIndicator = true//竖直

            //设置反弹效果

            self.ExampleScorllView.bounces = false

            //设置默认偏移量

            self.ExampleScorllView.contentOffset = CGPointMake(0, 300)

            

        }

        

        

        func scrollViewDidScroll(scrollView: UIScrollView) {

            print("X:(scrollView.contentOffset.x) Y:(scrollView.contentOffset.y)")

            print("滑动中")

        }

        

        func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {

            print("停止拖拽")

        }

        

        func scrollViewDidEndDecelerating(scrollView: UIScrollView) {

            print("停止滑动")

        }

        

        func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {

            return scrollView.subviews[0] as? UIView  

        }

        

        override func didReceiveMemoryWarning() {

            super.didReceiveMemoryWarning()

            // Dispose of any resources that can be recreated.

        }

        

    }

  • 相关阅读:
    maven~nexus开启游客下载
    springboot~thymeleaf为vue传递模型
    uppy实现断点续传
    skywalking的介绍
    springboot~disruptor异步队列
    [翻译]——Accelerated Database Recovery; Instant Rollback and Database Recovery
    SQL Server什么时候启用“锁定内存页”选项 (Windows)
    ORACLE重编译同义词(synonym)遇到ORA-01031总结
    杂想闲思录——你的努力付出可能毫无价值可言!
    CentOS 7下MySQL Sniffer安装总结
  • 原文地址:https://www.cnblogs.com/godlovexq/p/5286233.html
Copyright © 2011-2022 走看看