CGFloat width = +; CGFloat height= +; //Get screen width height//Get Screen ObjectUIScreen *screen =[UIScreen mainscreen]; //Get screen sizeCGRect Screenframe =[screen bounds]; //Take out the wide height of the screen individually//cgfloat screenwidth = screenFrame.size.width;CGFloat screenwidth =cgrectgetwidth (screenframe); //cgfloat screenheight = screenFrame.size.height;CGFloat screenheight =cgrectgetheight (screenframe);//x-Axis y-axis//Cgrectgetminx + cgrectgetminy = upper-left corner of view coordinates//cgrectgetmidx + cgrectgetmidy = Center coordinate of view//Cgrectgetmaxx + cgrectgetmaxy = upper-right corner of view coordinates//cgrectgetwidth + cgrectgetheight = size of view /*( minx/y) (midx/0) (maxx,y) +-----.-----+ | | . . . (Midx, Midy) | | +-----.-----+ */ //calculate the number of each columnCGFloat col = screenwidth/width; //calculate the number of each rowCGFloat row = screenheight/height; for(Nsinteger i =0; i < row; ++i) { for(Nsinteger j =0; J < Col; ++j) {UIView*v =[[UIView alloc] init]; //set line I, column J size of viewV.frame = CGRectMake (J * width, I *height, width, height); //Cgrectgetmidx (v.frame); //(v.frame.origin.x + v.frame.size.width)/2; //Cgrectgetmidy (v.frame); //(V.FRAME.ORIGIN.Y + v.frame.size.height)/2; //Set ColorV.backgroundcolor = [Uicolor colorwithred:arc4random ()% the/255.0Green:arc4random ()% the/255.0Blue:arc4random ()% the/255.0Alpha1]; //put it in the window display[Self.window addsubview:v]; } }
Suitable for all size printing mosaics