Cocoa API解説(macOS/iOS)

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。

目次

animationBlockingMode

INDEX>AppKit>NSAnimation

アニメーションブロックモード

解説

アニメーションブロックモード
他のアニメーションの動作をブロックするかどうかのモード
enum BlockingMode
.blocking ブロックする
.nonblocking
.nonblockingThreaded

設定値

Objective-C

@property NSAnimationBlockingMode animationBlockingMode


Swift

var animationBlockingMode: NSAnimationBlockingMode

NSAnimationBlockingMode

フレームワーク

ApplicationKit

クラス

NSAnimation

使用可能

10.4

更新時のバージョン

OS X 10.14
Swift5.1

関連記事(外部サイト)

例文

Objective-C

Swift5.1

//NSAnimation
    var theAnim014: NSAnimation!
    var theAnim014sub: NSAnimation!
    @IBOutlet weak var indicator014: NSProgressIndicator!
    @IBOutlet weak var indicator014sub: NSProgressIndicator!
    
    @IBOutlet weak var label014: NSTextField!
    @IBOutlet weak var label014sub: NSTextField!
    @IBAction func function014(sender: AnyObject) {
        //NSAnimationProgress
        var progMarks : [NSAnimation.Progress] =  [
            0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
            0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0  ]

        let count :Int = 20
        
        //アニメーション設定
        theAnim014 = NSAnimation(duration: 10.0, animationCurve: NSAnimation.Curve.easeInOut)
        
        theAnim014.frameRate = 20.0
        theAnim014.delegate = self
        
        theAnim014.animationBlockingMode = NSAnimation.BlockingMode.blocking
        
        theAnim014.animationCurve = NSAnimation.Curve.easeInOut
        theAnim014.duration = 15.0
        let mark1:NSAnimation.Progress = 0.3
        theAnim014.addProgressMark(mark1)
        
        //
        theAnim014sub = NSAnimation(duration: 10.0, animationCurve: NSAnimation.Curve.easeInOut)
        theAnim014sub.frameRate = 20.0
        theAnim014sub.delegate = self
        //Do not block other animations.
        theAnim014sub.animationBlockingMode = NSAnimation.BlockingMode.nonblockingThreaded
        theAnim014sub.animationCurve = NSAnimation.Curve.easeInOut
        theAnim014sub.duration = 15.0
        
        indicator014.doubleValue = 0
        //
        //Use "for in"
        for i in 0 ..< count {
            theAnim014!.addProgressMark(progMarks[i])
            print("set \(progMarks[i])")
        }
        for i in 0 ..< count {
            theAnim014sub!.addProgressMark(progMarks[i])
            print("set \(progMarks[i])")
        }
        slideBar.doubleValue = 0.0
        slideBar.maxValue = 1.0
        slideBar.minValue = 0.0
        
        indicator014.doubleValue = 0.0
        indicator014.maxValue = 1.0
        indicator014.minValue = 0.0
        
        indicator014sub.doubleValue = 0.0
        indicator014sub.maxValue = 1.0
        indicator014sub.minValue = 0.0
        //Asynchronous processing
        DispatchQueue.global(qos: .userInteractive).async {
            
            //Start  theAnim014sub when theAnim014 reaches the progress status 0.3
            self.theAnim014sub.start(when: self.theAnim014,reachesProgress:mark1)
            //Stop theAnim014sub when theAnim014 mark 10 is reached.
            self.theAnim014sub.stop(when: self.theAnim014,reachesProgress:progMarks[10])
            //Start theAnim014
            self.theAnim014.start()

            DispatchQueue.main.async {
                //Main therad(for UI update)
            }
        }
        
        
    }

Swift2.0

//NSAnimation animationBlockingMode
    //Swift 2.0
    @IBAction func function002(sender: AnyObject) {
        //NSAnimationProgress
        var progMarks : [NSAnimationProgress] =  [
            0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
            0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0  ]
        var i :Int
        let count :Int = 20
        //アニメーション設定
        theAnim002 = NSAnimation(duration: 10.0, animationCurve: NSAnimationCurve.EaseInOut)
        
        theAnim002!.frameRate = 20.0
        theAnim002!.delegate = self
        theAnim002!.animationBlockingMode = NSAnimationBlockingMode.Blocking

        //登録
        for (i = 0 ; i<count ; i++){
            theAnim002!.addProgressMark(progMarks[i])
            NSLog("bbb %f",progMarks[i])
        }
        dispatch_async(dispatch_get_main_queue()) {
            self.theAnim002!.startAnimation()
        }

        
    }

Swift 1.2

//NSAnimation animationBlockingMode
    @IBAction func function002(sender: AnyObject) {
        //NSAnimationProgress
        var progMarks : [NSAnimationProgress] =  [
            0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
            0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0  ]
        var i :Int
        var count :Int = 20
        //アニメーション設定
        theAnim002 = NSAnimation(duration: 10.0, animationCurve: NSAnimationCurve.EaseInOut)
        
        theAnim002!.frameRate = 20.0
        theAnim002!.delegate = self
        theAnim002!.animationBlockingMode = NSAnimationBlockingMode.Blocking

        //登録
        for (i = 0 ; i<count ; i++){
            theAnim002!.addProgressMark(progMarks[i])
            NSLog("bbb %f",progMarks[i])
        }
        dispatch_async(dispatch_get_main_queue()) {
            self.theAnim002!.startAnimation()
        }

        
    }

Swift1.1

    //NSAnimation animationBlockingMode
    @IBAction func function002(sender: AnyObject) {
        //NSAnimationProgress
        var progMarks : [NSAnimationProgress] =  [
            0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5,
            0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0  ]
        var i :Int
        var count :Int = 20
        //アニメーション設定
        theAnim002 = NSAnimation(duration: 10.0, animationCurve: NSAnimationCurve.EaseInOut)
        
        theAnim002.frameRate = 20.0
        theAnim002.delegate = self
        theAnim002.animationBlockingMode = NSAnimationBlockingMode.Blocking

        //登録
        for (i = 0 ; i<count ; i++){
            theAnim002.addProgressMark(progMarks[i])
            NSLog("bbb %f",progMarks[i])
        }
        dispatch_async(dispatch_get_main_queue()) {
            self.theAnim002.startAnimation()
        }

        
    }
//アニメーション
    func animation(animation: NSAnimation, didReachProgressMark progress: NSAnimationProgress) {

        if (animation == theAnim001){
                        NSLog("theAnim001")
        }else if (animation == theAnim002){
            NSLog("theAnim002")
        }
    }