UIImageView class provides a view container for displaying either a single image or for animating a series of images. In this example we are going to display an image inside a frame that is smaller in size. With the help of ContentMode UIViewContentModeScaleAspectFit we can scale the content to fit the size of the view by maintaining the aspect ratio. Please see the reference Guide for other content modes that may help you set the image respective to the view frame. In this tutorial we are going to learn the following
- Display an image on the screen
- How to resize the image to fit the view frame
- Animate a series of images
var imageViewObject :UIImageView
imageViewObject = UIImageView(frame:CGRectMake(0, 0, 100, 100));
imageViewObject.image = UIImage(named:"imageName.png")
self.view.addSubview(imageViewObject)
- How to resize the image to fit the view frame
orimageViewObject.contentMode = UIViewContentMode.ScaleToFill
orimageViewObject.contentMode = UIViewContentMode.ScaleAspectFit
imageViewObject.contentMode = UIViewContentMode.ScaleAspectFill
- Animate a series of images
UIView.animateWithDuration(1.0,
delay: 2.0,
options: .CurveEaseInOut | .AllowUserInteraction,
animations: {
self. imageViewObject.center = CGPoint(x: 75, y: 200)
},
completion: { finished in
println("Bug moved left!")
})
1 comments:
Write commentsThe King Casino Company - Ventureberg
ReplyIt was born in 1934. The Company ventureberg.com/ offers luxury hotels, If you don't have a poker room in novcasino your house, then you'll 바카라사이트 find 출장안마 a 바카라 사이트 poker room in the