Shaideru

All things iOS & Swift

iOS animation with Swift part1

Create a UIView named view1

let view1 = UIView(frame: CGRectMake(self.view.center.x, self.view.center.y, 60, 60))

change the background color of the view to any preferred color

view1.backgroundColor = UIColor.redColor() start animating the view by using animateWithDuration(duration: animations:)

UIView.animateWithDuration(5, animations: { () -> Void in
view1.center = CGPoint(x: 0, y: 0)
})

finally, add your view as a subview

self.view.addSubview(view1)

Leave A Comment

Your email address will not be published.