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: