UI Control (iOS)---uiimageview

Source: Internet
Author: User

In the implementation of network asynchronous storage, suddenly found that the control Uiimageview A little rusty, here to review a bit.

Uiimageview, As the name implies is used to place the image.

1. Initialize uiimageview

Uiimageview *imgshadow = [[uiimageview alloc] initwithframe:cgrectmake ( A. )];

[Imgshadow setimage:[UIImage imagenamed:@ "9.jpg"];

[Self. View addsubview:Imgshadow];

2. ForUiimageviewAdd Effect

// set border color

[Imgshadow. layer setBorderColor: [[uicolor whitecolor] Cgcolor];

Set Border Width

    [ Imgshadow. layer 1.0];

   // Set the projection offset, cgsizemake (X axis direction, Y axis direction)

[[Imgshadow layer] setshadowoffset: Cgsizemake(1, 1)];

set the projection color

[[Imgshadow layer] setshadowcolor: [uicolor Redcolor]. Cgcolor];

set the projection radius

[[Imgshadow layer] Setshadowradius:3];

Set Transparency

[[Imgshadow layer] setshadowopacity:1];

When set toYes, beyond the bounds will be obscured(hidden ), often with Cornerradius, attributes used. This way, the area outside the fillet will be obscured

[Imgshadow. Layer setmaskstobounds:YES];   

Set rounded corners

Imgshadow. layer. Cornerradius = ten;

3. Change location

Change the location of a uiimageview, you can

3.1 Modify its Frame property directly

3.2 Modify its Center property:

Imageview.center = Cgpointmake (CGFloat x, cgfloat y);

The Center property refers to the middle point of the ImageView.

3.3 Using the Transform property

Imageview.transform = cgaffinetransformmaketranslation (cgfloat dx, cgfloat dy);

where dx and dy indicate how much you want to move in the X or Y direction, rather than how much to move.

4. Rotate the image

Imageview.transform = cgaffinetransformmakerotation (cgfloat angle);

Note that it rotates in a clockwise direction, and the center of the rotation is the center of the original ImageView, which is the position represented by the Center property.

The parameter of this method is angle in radians, not our most commonly used degree, so you can write a macro definition:

#define Degreestoradians (x) (m_pi* (x)/180.0)

Small write incomplete, if there is omission, please contact!!!

UI Control (iOS)---uiimageview

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.