Ios-based UIImageView and iosuiimageview
UIImageView
UIImageView is a subclass of UIView. Its main function is to display images.
Create a UIImage object
UIImage*Image= [UIImageimageNamed:@ "Qwer.jpg"];
Create a UIImageView object imageView. The initialization method is initWithImage :.
You must pass a parameter of the UIImage type. This parameter is the image to be displayed in the imageView.
Upload the created image.
UIImageView*ImageView= [[UIImageView alloc]InitWithImage:Image];
Add the imageView to the parent view.
[Self.View addSubView:ImageView];
UIImageCommon creation methods
1. UIImage * image = [UIImage imageNamed: @ "1.jpg"];
Small images are often used. They are first loaded into the cache and then returned.
2. UIImage * image = [UIImage imageWithContentsOfFile: path];
UIImageView * imageView = [[UIImageView alloc] initWithImage: image];
Large images are not frequently used and are not cached
Select imageView to display the image Style
UIImageView provides a variety of image display styles, by the UIViewContentMode attribute con
TentMode. UIViewContentMode is an enumeration type and provides 13 styles.
Three Common display modes: UIViewContentModeScaleToFill, UIViewContentModeScaleAspectFit, UIViewContentModeScaleAspectFill, and UIViewContentModeScaleToFill assign different image display effects to the contentMode attribute of imageView.
1, imageView. contentMode = UIViewContentModeScaleToFill;
The image will be filled with the entire imageView, and the entire image will be fully displayed,
Because the aspect ratio of the original image is different from that of the imageView, the image will be deformed,
2, imageView. contentMode = UIViewContentModeScaleAspectFit;
The image is completely displayed, and the entire image maintains the aspect ratio, but the image is reduced
So the imageView is not filled with images,
3, imageView. contentMode = UIViewContentModeScaleAspectFill;
The image will maintain the aspect ratio and original size, but will not be completely displayed by the imageView
ImageViewFrame
Set the imageView position and size
ImageView. frame = CGRectMake (CGFloat x, CGFloat y, CGFloat width, CGFloat height );
If no imageView frame is set, it will be the same as the image
Statement: Reference Dane notes