• 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.

        }

        

    }

  • 相关阅读:
    Dos常用命令
    Typora的使用技巧
    Spring入门(2)
    (转)Oracle中判断某字段不为空及为空的SQL语句
    ReadOnly与Enabled
    邮件无法发送大文件,分卷压缩
    关于easyui checkbox 的一些操作处理
    JS 判断某变量是否为某数组中的一个值 的几种方法
    Oracle把逗号分割的字符串转换为可放入in的条件语句的字符数列
    C#区分大小写
  • 原文地址:https://www.cnblogs.com/godlovexq/p/5286233.html
Copyright © 2020-2023  润新知