2012-07-12 4 views

답변

2

신속하고 더러운 단지

class AppDelegate 
    def application(application, didFinishLaunchingWithOptions:launchOptions) 
    @window = UIWindow.alloc.initWithFrame UIScreen.mainScreen.bounds 
    @window.makeKeyAndVisible 

    my_view = UIView.alloc.initWithFrame [[0, 0], [50, 50]] 
    my_view.backgroundColor = UIColor.greenColor 
    @window.addSubview my_view 

    UIView.animateWithDuration(0.25, animations: lambda { 
     new_frame = my_view.frame 
     new_frame.origin = [100, 100] 
     my_view.frame = new_frame 
    }) 
    true 
    end 
end 
0

다음 코드는 객체를 애니메이션에 사용할 수있는 사용을 표시합니다.

  my_view = UIView.alloc.initWithFrame [[0, 0], [50, 50]] 
      my_view.backgroundColor = UIColor.greenColor 
      view.addSubview my_view 

      my_view.frame = [[0,0],[0,0]] #the position from which animation begins 
      UIView.beginAnimations(nil,context:nil) 
      UIView.setAnimationDuration(0.05) 
      UIView.setAnimationDelay(0.2) 
      UIView.setAnimationCurve(UIViewAnimationCurveEaseOut) 
      my_view.frame = [[250,400],[50,50]] # the position at which the animation ends 
      my_view.backgroundColor = UIColor.blueColor #you can also change other properties while animating 
      UIView.commitAnimations 
0

sugarcube!

frame = my_view.frame 
frame.origin = point_a 
my_view.frame = frame 

# animating the move to point_b is EASY 
my_view.move_to point_b 
0

Walt을보고 싶을 수도 있습니다.

{ 
    move: "my_id", 
    from: [10, 10], 
    to: [50, 50] 
    } 
관련 문제