The Uiimageview of the Ios-ui control

Source: Internet
Author: User

Contentmode Property
    • With scale words: pictures may stretch

      • Uiviewcontentmodescaletofill
        • Stretch the picture to fill the entire ImageView
        • The picture shows the same size as the ImageView.
      • With aspect Words: Maintain the original aspect ratio of the picture
        • Uiviewcontentmodescaleaspectfit
          • Guaranteed to just see all the pictures.
        • Uiviewcontentmodescaleaspectfill
          • Stretch to the width or height of the picture as ImageView
    • No scale words: The picture will never be stretched, keeping the original size of the picture

      • Uiviewcontentmodecenter
      • Uiviewcontentmodetop
      • Uiviewcontentmodebottom
      • Uiviewcontentmodeleft
      • Uiviewcontentmoderight
      • Uiviewcontentmodetopleft
      • Uiviewcontentmodetopright
      • Uiviewcontentmodebottomleft
      • Uiviewcontentmodebottomright
Small grammar points
    • Cannot modify directly: Member of the Structure property of the OC object
    • The following wording is wrong.
imageView.frame.size = imageView.image.size;
    • Correct wording
CGRect tempFrame = imageView.frame;tempFrame.size = imageView.image.size;imageView.frame = tempFrame;
Initwithimage: Method
    • The size of the ImageView created with this method is the same as the size of the incoming image
3 Ways to modify a frame
    • Directly using the CGRectMake function
imageView.frame = CGRectMake(100, 100, 200, 200);
    • Take advantage of temporary struct-body variables
CGRect tempFrame = imageView.frame;tempFrame.origin.x = 100;tempFrame.origin.y = 100;tempFrame.size.width = 200;tempFrame.size.height = 200;imageView.frame = tempFrame;
    • Use curly braces {} form
imageView.frame = (CGRect){{100, 100}, {200, 200}};
  • Extracting Duplicate Code

    • Put the same code in a new method
    • What is not used becomes the parameter of the method.
  • How pictures are loaded

      • has a cache
         uiimage *image = [
          uiimage imagenamed:@ "picture name"];     
        • Use cases: pictures are smaller and use more frequently
        • recommends placing images that need to be cached directly to Images.xcassets
      • No cache
         nsstring *file = [[@ "picture name" Oftype:@ "image Extension"] ; uiimage *image = [uiimage Imagewithcontentsoffile:@ "full path to picture file"];         
        • Use cases: Pictures larger, less frequently used
        • images that do not need to be cached cannot be placed in Images.xcassets
        • when placed in supporting files, select Create folder when importing References, loading a document requires importing the file name '/images/imag_01 '
      • the picture in Images.xcassets, which can only be loaded with the image name
  • Delay doing some things

[abc performSelector:@selector(stand:) withObject:@"123" afterDelay:10];// 10s后自动调用abc的stand:方法,并且传递@"123"参数
    • Simple playback of audio files
// 创建一个音频文件的URL(URL就是文件路径对象)NSURL *url = [[NSBundle mainBundle] URLForResource:@"音频文件名" withExtension:@"音频文件的扩展名"];// 创建播放器self.player = [AVPlayer playerWithURL:url];// 播放[self.player play];

Ios-ui control's 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.