2013-10-11 31 views
-2

努力試圖繪製一個矩形中的UITableViewCellUIRectFill沒有在iOS的7

//Works with iOS6 and earlier but NOT with (iOS7) 

- (void)drawRect:(CGRect)rect { 
    // Creating a black border 
    [[UIColor blackColor] setFill]; 
    UIRectFill(CGRectMake(10, 5, 40, 43)); 

    // Filling with rig color 
    [[UIColor colorWithRed:r green:g blue:b alpha:a] setFill]; 
    UIRectFill(CGRectMake(11, 6, 38, 41)); 
} 

有誰知道爲什麼,這並不在iOS中7工作,但確實在iOS 6中?

+0

呃......爲什麼它不工作會有所幫助一些更多的信息。 – GuybrushThreepwood

+0

那是什麼,我想弄清楚到底爲什麼不與iOS7工作。你可以用你的任何UItableViewCell類來檢查這個方法嗎? –

回答

1

我有同樣的問題的iOS 7下 - 任何你在-drawRect方法來繪製得到由細胞的子視圖掩蓋。取而代之的是,一個新的視圖子類作爲一個子視圖的一個實例添加到您的細胞contentView並做圖紙那裏。

thisthis。如果你不想箱子一個自定義子類,你可以使用block drawing views代替。

+0

謝謝MrMage給我提示。 –

0

我已經通過添加一個子視圖固定它內容查看

- (id)initWithStyle:(UITableViewCellStyle)style 
           reuseIdentifier:(NSString *)reuseIdentifier{ 
     if(!self) 
     return self; 

     self.colorView = [[UIView alloc] initWithFrame:CGRectMake(10, 5, 40, 43)]; 
     self.colorView.layer.borderColor = [[UIColor blackColor] CGColor]; 
     self.colorView.layer.borderWidth = 1.0; 
     [self.contentView addSubview:self.colorView]; 

    } 

- (void)setActivityColor:(UIColor*)color 
{ 
    [self.colorView setBackgroundColor:color]; 
}