Implementation of IOS jiugongge

Source: Internet
Author: User

Implementation of IOS jiugongge

Display images as required in the form of nine Cells

Basic Ideas

// You can change the int columnCount = 3 to display the total number of columns. // the width and height of the no-lattice CGFloat appW = 85.0; CGFloat appH = 95.0; // calculate the gap CGFloat appMargin = (self. view. frame. size. width-columnCount * appW)/(columnCount + 1); // read resource file _ apps. count indicates the number of resources NSString * path = [[NSBundle mainBundle] pathForResource: @ "myAppRes. plist "ofType: nil]; _ apps = [NSArray arrayWithContentsOfFile: path]; for (int I = 0; I <_ apps. count; I ++) {UIView * vi = [[UIView alloc] init]; vi. backgroundColor = [UIColor greyColor]; // calculate the column number and the row number int colX = I % columnCount; int rowY = I/columnCount; // calculate the coordinate CGFloat appX = appMargin + colX * (appW + appMargin); CGFloat appY = 30 + rowY * (appH + appMargin); vi. frame = CGRectMake (appX, appY, appW, appH); [self. view addSubview: vi];

You only need to change the total number of columns and the width and height to display the expected results:






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.