ios - Positioning Multiple UIImage's - Objective C -


in app i'm building, square image imported, broken 16 tiles, , tiles placed in square on screen, starting top. however, i'm adding bar of info @ top above tiles, need move set of tiles further down screen. i've played around loop , coordinates code makes, nothing giving me desired respect.

-(void) initpuzzle:(nsstring *) imagepath{ uiimage *orgimage = [uiimage imagenamed:imagepath]; if( orgimage == nil ){ return; } [self.tiles removeallobjects]; tilewidth = orgimage.size.width/num_horizontal_pieces; tileheight = orgimage.size.height/num_vertical_pieces; blankposition = cgpointmake( num_horizontal_pieces-1, num_vertical_pieces-1 ); for( int x=0; x<num_horizontal_pieces; x++ ){ for( int y=0; y<num_vertical_pieces; y++ ){ // *** coordinates need altered - ? cgpoint orgposition = cgpointmake(x,y); if( blankposition.x == orgposition.x && blankposition.y == orgposition.y ){ continue; } cgrect frame = cgrectmake(tilewidth*x, tileheight*y, tilewidth, tileheight ); cgimageref tileimageref = cgimagecreatewithimageinrect( orgimage.cgimage, frame ); uiimage *tileimage = [uiimage imagewithcgimage:tileimageref]; cgrect tileframe = cgrectmake((tilewidth+tile_spacing)*x, (tileheight+tile_spacing)*y, tilewidth, tileheight ); tileimageview = [[tile alloc] initwithimage:tileimage]; tileimageview.frame = tileframe; tileimageview.originalposition = orgposition; tileimageview.currentposition = orgposition; cgimagerelease( tileimageref ); [tiles addobject:tileimageview]; // add view [self.view insertsubview:tileimageview atindex:0]; } } [self shuffle]; 

}

int topbarwidth = 100; //100 based on example in comment 

then @ point in code you're setting frames of each tile, add topbarwidth whatever y value setting.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -