zoukankan      html  css  js  c++  java
  • 点击按钮,使按钮进行左右翻转动画

     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 }
  • 相关阅读:
    VBS发送邮件-1
    docker命令
    NLP | 自然语言处理
    windows: Python安装scipy,scikit-image时提示"no lapack/blas resources found"的解决方法
    Sense2vec with spaCy and Gensim
    python 去停用词
    nohup command > myout.file 2>&1 &
    NLTK vs SKLearn vs Gensim vs TextBlob vs spaCy
    Gensim进阶教程:训练word2vec与doc2vec模型
    Gensim入门教程
  • 原文地址:https://www.cnblogs.com/panda1024/p/6245911.html
Copyright © 2011-2022 走看看