我想創建一個tableview,它具有一些圓形子視圖作爲UIView。我設置了UIView的layer.cornerRadius和clipsToBounds。但是有些觀點並不全面。誰可以幫我解決這個問題或給我一些建議?UITableViewCell的子視圖不能輪迴
我的代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * settCellID = @"settingCellID";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:settCellID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:settCellID];
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(100, 10, 20, 20)];
view.layer.cornerRadius = 10;
view.clipsToBounds = 1;
view.layer.rasterizationScale = [UIScreen mainScreen].scale;
view.layer.shouldRasterize = 1;
view.backgroundColor = [UIColor blueColor];
[cell.contentView addSubview:view];
}
return cell;
}
結果:
這是發生在設備上還是在模擬器上? – beyowulf
作爲行高返回的值是多少。比這個圓形視圖的高度大。 –
這是發生在模擬器?那麼就有模擬器毛刺的可能性。將模擬器的比例設置爲100%(在菜單:窗口 - >比例 - > 100%)然後檢查。 – Jeyamahesan