Learning iOS (Uiimageview) controls and their properties from scratch

Source: Internet
Author: User
Tags border color

Set the frame's properties and size when you create a picture view

Uiimageview *img = [[Uiimageview alloc] Initwithframe:cgrectmake (60, 20, 80, 100)];

[img setimage:[uiimage imagenamed:@ "mtxx6"];

/* Another four ways to create a picture view

Type img{

Uiimageview *IMG1 = [[Uiimageview alloc]init];

Uiimageview *IMG2 = [[Uiimageview ALLOC] Initwithimage: (UIImage *)];

Uiimageview *IMG3 = [[Uiimageview alloc] Initwithimage: (UIImage *)];

Uiimageview *IMG4 = [[Uiimageview alloc] Initwithcoder: (Nscoder *)];

}uiimageview

*/

Set the properties of a frame to set its position and size

Img.frame = CGRectMake (CGFloat x, cgfloat y, < #CGFloat Width#>, < #CGFloat height#>)

Bounds can only set its size, bounds is to scale the Uiimageview control in its original center.

Img.bounds = CGRectMake (< #CGFloat X#>, < #CGFloat Y#>, < #CGFloat Width#>, < #CGFloat height#>)

Contentmode set how the picture is displayed. I set to zoom out by the view

Img.contentmode = Uiviewcontentmodescaleaspectfit;

Uiviewcontentmodescaleaspectfill guarantee that part of the picture is the same, but it fills the whole imageview, and maybe only some of the pictures show up.

Uiviewcontentmodescaleaspectfit displays all the image in view according to the scale of the view, so the view is partially blank

Uiviewcontentmodescaletofill pictures are then populated according to the size of the Picture view window, causing the picture to deform

Uiviewcontentmoderedraw control of the view appearance during scaling and resizing

Uiviewcontentmodecenter picture shows the original size showing the middle part,

Uiviewcontentmodetop picture shows the original size showing the upper part

Uiviewcontentmodebottom picture shows the original size showing the following section

Uiviewcontentmodeleft picture shows the original size showing the left part

Uiviewcontentmoderight picture shows the original size showing the right part

Uiviewcontentmodetopleft picture shows the original size showing the upper left part

Uiviewcontentmodetopright Picture Displays the original size showing the upper right part

Uiviewcontentmodebottomleft picture shows the original size showing the lower left part

Uiviewcontentmodebottomright picture shows the original size showing the lower right part

Img.center = Cgpointmake (40.0, 80.0);

Center change the location of Uiimangeview

Img.transform = Cgaffinetransformmakerotation (60.0);

Transfrom clockwise rotation around the center of the ImageView

Img.transform = Cgaffinetransformmakescale (8.0,2.0);

Transform Scaling an image

[Img.layer Setbordercolor:[[uicolor Redcolor] cgclolor];

[Img.layer Setbordercolor:[[uicolor Redcolor] cgcolor];

BorderColor Setting the border color

Img.hidden = no;//no to show picture, yes to hide picture

Img.alpha = 0.5;//Set Transparency

Img.highlightedimage = [UIImage imagenamed:@ "mtxx9"];

[Img.layer setbordercolor: [[Uicolor Whitecolor] cgcolor];

Setshouldrasterize set rasterization, no not rasterized, yes the data in the grid layer

[Img.layer Setshouldrasterize:no];

/*

Imagearray represents an array

Img.animationimages = Imagearray;

Set all the pictures to play in a few seconds

Img.animationduration = [Imagearray count];

Do not repeat how many times, o means countless times

Img.animationrepeatcount = 0;

Start playback

[img Startanimating];

*/

Adjust picture size to content picture

[img SizeToFit];

[Self.view addsubview:img];

Learning iOS (Uiimageview) controls and their properties from scratch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.