zoukankan      html  css  js  c++  java
  • Xcode9学习笔记59

        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
            let rect = CGRect(x: 58, y: 40,  200, height: 200)
            let imageView = UIImageView(frame: rect)
            let image = UIImage(named: "Pic")
            imageView.image = image//给图像视图添加要显示的图片
            imageView.tag = 1//设置图像视图的标识值,以方便后期对图像视图的调用
            
            self.view.addSubview(imageView)
            
            let button = UIButton(type: UIButtonType.system)//初始化一个按钮对象,点击按钮时播放动画
            button.frame = CGRect(x: 58, y: 400,  200, height: 44)
            button.backgroundColor = UIColor.lightGray
            button.setTitle("Tap", for: UIControlState())
            button.addTarget(self, action: #selector(ViewController.playAnimation), for: UIControlEvents.touchUpInside)
            
            self.view.addSubview(button)
        }
        
        @objc func playAnimation() {
            UIView.beginAnimations(nil, context: nil)//发出开始动画的请求
            UIView.setAnimationCurve(.easeOut)//设置动画的播放速度为淡入淡出
            UIView.setAnimationDuration(5)//设置动画时长5秒
            UIView.setAnimationBeginsFromCurrentState(true)//设置动画从当前状态开始播放
            let view = self.view.viewWithTag(1)//通过标识值找到之前创建的图像视图,作为动画的载体
            UIView.setAnimationTransition(.flipFromRight, for: view!, cache: true)//设置动画类型为翻转动画
            UIView.commitAnimations()//调用视图的提交动画方法,标志着动画块的结束
        }
    

      

  • 相关阅读:
    Authentication for the REST APIs
    Authentication for the REST APIs
    泛型转Datatable
    Web API 返回json文件的2中不用方式
    Robotframework自定义关键字库
    python通过接口上传图片造测试数据
    robot framework(2) 环境搭建
    RobotFrameWork(1) 关键字驱动测试框架
    python发送带附件的邮件
    解决adb连接海马玩模拟器
  • 原文地址:https://www.cnblogs.com/LisenH/p/7849285.html
Copyright © 2011-2022 走看看