macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

initWithDuration:animationCurve:

INDEX>AppKit>NSAnimation

継続時間とアニメーションカーブで初期化して返します

Objective-C

-(id)initWithDuration:(NSTimeInterval)duration:
                 animationCurve:(NSAnimationCurve)animationCurve:

Swift

 init(duration duration: NSTimeInterval,
animationCurve animationCurve: NSAnimationCurve)

解説

指定の継続時間とアニメーションカーブで初期化されたNSAnimationオブジェクトを返します。

返り値

Objective-C

( id )

Swift

初期化されたNSAnimationインスタンス
初期化が出来なければnilが返されます。

引数

Objective-C

( NSTimeInterval )duration

Swift

duration duration: NSTimeInterval,

Objective-C

( NSAnimationCurve )animationCurve

Swift

animationCurve animationCurve: NSAnimationCurve

アニメーションカーブ
NSAnimationCurve

フレームワーク

ApplicationKit

クラス

NSAnimation

使用可能

10.4

更新時のバージョン

OS X 10.11
Swift 2.0

参照

例文

Objective-C

animation = [[TabViewAnimation alloc] initWithDuration:(slowMotionDemo ? TRANSITION_SLOWMO_DURATION : TRANSITION_DURATION) animationCurve:NSAnimationEaseInOut];

Swift2.0

@IBOutlet weak var window: NSWindow!
    var theAnim001: NSAnimation?
    var theAnim002: NSAnimation?
    var theAnim003: NSAnimation?
    var theAnim004: NSAnimation?
    var theAnim005: NSAnimation?
    var theAnim006: NSAnimation?
    var theAnim007: NSAnimation?
    var theAnim008: NSAnimation?
    var theAnim009: NSAnimation?
    var theAnim010: NSAnimation?
    var theAnim011: NSAnimation?
    var theAnim012: NSAnimation?
    var theAnim012sub: NSAnimation!
    
    //NSAnimation init
    //Swift2.0
    @IBAction func function001(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
        //アニメーション設定
        theAnim001 = NSAnimation(duration: 10.0, animationCurve: NSAnimationCurve.EaseInOut)
        
        theAnim001!.frameRate = 20.0
        theAnim001!.delegate = self
        //登録
        for (i = 0 ; i<count ; i++){
            theAnim001!.addProgressMark(progMarks[i])
            NSLog("bbb %f",progMarks[i])
        }
        dispatch_async(dispatch_get_main_queue()) {
            self.theAnim001!.startAnimation()
        }
    }
    //アニメーション
    func animation(animation: NSAnimation, didReachProgressMark progress: NSAnimationProgress) {
        
        if (animation == theAnim001){
            NSLog("theAnim001")
        }
        if (animation == theAnim002){
            NSLog("theAnim002")
        }
        if (animation == theAnim003){
            NSLog("theAnim003")
        }
        
        if (animation == theAnim004){
            NSLog("theAnim004")
        }
        if (animation == theAnim005){
            NSLog("theAnim005")
        }
        if (animation == theAnim006){
            NSLog("theAnim006")
        }
        if (animation == theAnim007){
            NSLog("theAnim007")
        }
        if (animation == theAnim008){
            NSLog("theAnim008")
        }
        if (animation == theAnim008){
            NSLog("theAnim008")
        }
        if (animation == theAnim009){
            NSLog("theAnim009 %.1f",theAnim009!.currentProgress)
            if (theAnim009!.currentProgress > 0.5){
                theAnim009!.stopAnimation()
                NSLog("end")
            }
        }
        if (animation == theAnim010){
            NSLog("theAnim010 %.1f",theAnim010!.currentProgress)
            if (theAnim010!.currentProgress > 0.5){
                theAnim010!.stopAnimation()
                NSLog("end")
            }
        }
        if (animation == theAnim011){
            NSLog("theAnim011 %.2f %.2f ",theAnim011!.currentValue,progress)
            if (theAnim011!.currentProgress > 0.8){
                theAnim011!.stopAnimation()
                NSLog("end")
            }
        }
        if (animation == theAnim012){
            NSLog("theAnim012 %.2f",theAnim012!.currentValue,progress)
        }

        
        
    }