我正在使用UIImageView
作爲我編程創建的UITableViewCell
中的accessoryView
。我嘗試了所有我能想到的設置accessoryView
的alpha
屬性,但它不起作用。我能夠設置hidden
和opaque
屬性沒有問題,但alpha
是恨我的。是否可以設置UITableViewCell accessoryView的alpha屬性?
我試圖創建一個包含單一UITableViewController
及以下tableView:cellForRowAtIndexPath:
方法一個新的項目:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Cell";
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
cell.accessoryView = iv;
[iv release];
// cell.accessoryView.hidden = YES; // works
cell.accessoryView.alpha = 0.5f; // fails
return cell;
}
正如你可能已經猜到了,accessoryView
是完全不透明的。我錯過了什麼嗎?我找不到有關這裏發生了什麼的任何信息。
謝謝!
剛剛遇到了這個之後,它攪亂了大約半小時,直到我放棄了。很高興看到我並不孤單。 :D感謝您發佈解決方法。雖然很無聊! – taber 2011-07-29 22:16:25
這仍然不能在iOS 5.1中設置。我也嘗試在設置它作爲accessoryView之前設置UIImageView的alpha,但是這也沒有做任何事。 – arlomedia 2012-09-06 18:08:24