• 点击按钮,使按钮进行左右翻转动画


     1 // UIView.transition
     2 
     3 // 1、可以设置从一个View到另一个View的转场动画
     4 // UIView.transition(from: <#T##UIView#>, to: <#T##UIView#>, duration: <#T##TimeInterval#>, options: <#T##UIViewAnimationOptions#>, completion: <#T##((Bool) -> Void)?##((Bool) -> Void)?##(Bool) -> Void#>)
     5 
     6 // 2、可以设置一个View的动画(比如翻转)
     7 // UIView.transition(with: <#T##UIView#>, duration: <#T##TimeInterval#>, options: <#T##UIViewAnimationOptions#>, animations: <#T##(() -> Void)?##(() -> Void)?##() -> Void#>, completion: <#T##((Bool) -> Void)?##((Bool) -> Void)?##(Bool) -> Void#>)
     8 
     9 import UIKit
    10 
    11 class ViewController: UIViewController {
    12     
    13     private var isZhengMian:Bool = true
    14     
    15     override func viewDidLoad() {
    16         super.viewDidLoad()
    17     }
    18     
    19     @IBAction func btnClick(_ sender: UIButton) {
    20         isZhengMian = !isZhengMian
    21         if isZhengMian{ // 正面,带文字,从左向右翻转
    22             UIView.transition(with: sender, duration: 0.5, options: UIViewAnimationOptions.transitionFlipFromLeft, animations: {
    23                 sender.setTitle("", for: .normal)
    24             }, completion: { (_) in
    25                 
    26             })
    27         } else{ // 反面,不带文字,从右向左翻转
    28             UIView.transition(with: sender, duration: 0.5, options: UIViewAnimationOptions.transitionFlipFromRight, animations: {
    29                 sender.setTitle(nil, for: .normal)
    30             }, completion: { (_) in
    31                 
    32             })
    33         }
    34     }
    35 }
  • 相关阅读:
    Ubuntu 18.04 安装博通(Broadcom)无线网卡驱动
    Python3漏洞扫描工具 ( Python3 插件式框架 )
    Linux 防火墙
    基于Python3的漏洞检测工具 ( Python3 插件式框架 )
    git学习笔记
    sublime text 3 优化配置
    win10 出现0x80072efd错误
    Ubuntu搭建NFS服务器,NFS协议详细分析
    docker实现跨主机连接
    Python-RabbitMQ(持久化)
  • 原文地址:https://www.cnblogs.com/panda1024/p/6245911.html
Copyright © 2020-2023  润新知