Code creation
/**
Create Uiimageview
*/
Uiimageview * Imageview=[[uiimageview Alloc]init];
/**
Set the size position
*/
Imageview.frame= (CGRect) {{50,50},{230,230}};
/**
Create a picture
*/
UIImage * Image=[[uiimage Alloc]init];
/**
Get Pictures
*/
Image=[uiimage imagenamed: @ "picture name"];
/**
Give the picture to the container
*/
imageview.image=image;
/**
< images with scale words may be stretched >
Uiviewcontentmodescaletofill
Stretch the picture to fill the entire ImageView
The picture shows the same size as the ImageView.
With scale words, with aspect words: may be stretched, but will maintain the image's original aspect ratio
Uiviewcontentmodescaleaspectfit
Guaranteed to just see all the pictures.
Uiviewcontentmodescaleaspectfill
Stretch to the width or height of the picture as ImageView
Words < images without scale will never be stretched, keeping the original width and height of the image
*/
Imageview.contentmode=uiviewcontentmodescaleaspectfit;
/**
The out-of-section is clipped
*/
imageview.clipstobounds=yes;
[Self.view Addsubview:imageview];
Picture loading
-No cache
NSString *file = [[NSBundle mainbundle] pathforresource: @ "picture name" oftype:@ "picture extension"];
UIImage *image = [UIImage imagewithcontentoffile:file];
* As long as the method name is file, all paths are passed
Use occasions: The picture is bigger, the use frequency is relatively low
Recommendation: Images that do not need to be cached cannot be placed in Images.xcassets
-There is a cache
UIImage *image =[uiimage imagenamed: @ "picture name"];
Use occasions: Pictures relatively small, the use of high frequency ratio
Recommendation: Place images that need to be cached in Images.xcassets
Audio file Playback
//Create a URL for an audio file (URL is the path object of the file)
Nsurl *url = [[NSBundle mainbundle] urlforresource: @ "audio filename" withextention:@ "audio file extension"];
--Another wording
Nsurl *url = [[NSBundle mainbundle] urlforresource: @ "audio file name extension" Withextention:nil ";
//Create player
Self.palyer = [Avplayer playerwithurl:url];
[Self.player play];
Deferred Call method
[OBJC performselector: @selector (stand:) withobject:@ "123" afterdelay:10];
After 10 seconds, call OBJC's stand: method, and pass the @ "123" parameter
Withobject can be any object
Xcode Uiimageview creation, picture loading, audio file playback, deferred invocation