2012-04-08 77 views
0

我的tableView細胞具有梯度層如何重新定位於旋轉

CAGradientLayer *gradient = [CAGradientLayer layer]; 
    gradient.frame = cell.contentView.bounds; 
    gradient.colors = 
    [NSArray arrayWithObjects: 
    (id)[[UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1] CGColor], 
    (id)[[UIColor colorWithRed:0.82 green:0.82 blue:0.82 alpha:1] CGColor], nil]; 
    [cell.contentView.layer insertSublayer:gradient atIndex:0]; 

其中,在旋轉時明顯保留在初始尺寸,直到我打電話

tableview.reloadData

我不知道是否有比這更復雜的方法。

這同樣與在中心有一個形象的NavigationController,

UIImage *logo = [UIImage imageNamed:@"logo.png"]; 
UIImageView *logoimageview = 
[[UIImageView alloc] initWithFrame: 
CGRectMake(self.navigationController.navigationBar.bounds.size.width/2 - logo.size.width/2, 
      self.navigationController.navigationBar.bounds.size.height/2 - logo.size.height/2, 
      logo.size.width, logo.size.height)]; 

[logoimageview setImage:logo]; 

[self.navigationController.navigationBar addSubview:logoimageview]; 

使圖像不旋轉時祭出,我不知道在航行的任何「刷新」的方法酒吧。

回答

1

我必須警告你,我沒有測試這個,但我希望它應該工作,當你設置autoresizingMask。對於表視圖細胞:

cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 

用於標識圖像視圖:

logoimageview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;