ios - Generated subview is always behind image view -


viewcontroller.m

-(void) viewdidload {     [super viewdidload];      [self addscorerowviewwithindexleft:(++i) andname:[scoredict objectforkey:@"name"] andscore:[[scoredict objectforkey:@"points"] integervalue]]; }  -(void) addscorerowviewwithindexleft:(nsinteger)index andname: (nsstring *)name andscore: (nsinteger)score {      uiview *scorerowview   = [[uiview alloc] initwithframe:cgrectmake(128, 112 + index * 80, 280, 20)];      uilabel *indexlabel    = [[uilabel alloc] initwithframe:cgrectmake(20, 20, 20, 20)];      uilabel *namelabel     = [[uilabel alloc] initwithframe:cgrectmake(150, 20, 180, 20)];      uilabel *scorelabel    = [[uilabel alloc] initwithframe:cgrectmake(330, 20, 50, 20)];      uicolor *color = [uicolor darkgraycolor];      [indexlabel settext:[@((int)index) stringvalue]];     [indexlabel setfont:[uifont fontwithname:@"dinalternate-bold" size:18]];     [indexlabel settextcolor:color];      [namelabel settext:name];     [namelabel setfont:[uifont fontwithname:@"dinalternate-bold" size:18]];     [namelabel settextcolor:color];      [scorelabel settext:[@((int)score) stringvalue]];     [scorelabel setfont:[uifont fontwithname:@"dinalternate-bold" size:18]];     [scorelabel settextcolor:color];      [scorerowview addsubview:indexlabel];     [scorerowview addsubview:namelabel];     [scorerowview addsubview:scorelabel];      [self.view addsubview:scorerowview]; } 

i added imageview in storyboard subview of view.

when delete imageview, ok. displayed other code generated subviews. when add imageview in storyboard, it's on top of other subviews. if give imageview alpha of 0.3 can see subviews shining through.

what's wrong code? tried;

[self.view bringsubviewtofront:scorerowview]; 

but doesn't work.

what can do?

try change zposition of imageview , scorerowview. can this way:

  1. connect imageview viewcontroller
  2. in bottom of viewdidload add that:

    yourimageview.layer.zposition = 1; scorerowview.layer.zposition = 2; 

i'm suspecting [self.view bringsubviewtofront:scorerowview]; doesn't work because invoke in viewdidload view in not work. can try invoke in e.g. viewdidappear , check if work.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -