[英]UITableView - Highlighting Selected Cell [iOS]
我已經創建了一個自定義TableCell的UITableView,通常遵循本教程;
http://www.theappcodeblog.com/?p=353
我根據自己的需求定制了它,看起來很棒。 但是,當我選擇一行時,它會通過將整個事物更改為藍色來突出顯示該行。 這個亮點涵蓋整個單元格並覆蓋內容,有效地制作一個看起來很討厭的大藍盒子。 我已經嘗試了備用突出顯示選項
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
顯然,如果選擇為灰色,則會出現相同的行為,但會出現灰色的丑陋框。 “無”是最好的選擇,但不能為我的用戶提供良好的體驗,因為我想表明他們已經選擇了那一行。
任何人都可以建議一種方法來顯示該行是高亮的,但仍然顯示下面的文字? 半透明度?
謝謝
也許是因為您的示例代碼設置為:
artistLabel.highlightedTextColor = [UIColor clearColor];
。
當高亮顯示時,它會使artistLabel的文字顏色變得透明。
因為您可以為標簽的highlightTextColor屬性設置自己的顏色,例如:
[UIColor whiteColor]
UITableView Cell選擇了Color
請享用...
// Image
UIImage *selectionBackground = [UIImage imageNamed:@"g7.png"];
UIImageView *bgview=[[UIImageView alloc] initWithImage:selectionBackground];
cell.selectedBackgroundView=bgview;
[bgview release];
要么
// Color
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor brownColor]];
[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];
你可以使用自己的自定義視圖來選擇
在這里,我有綠色的顏色。你可以改變你想要的任何定制。
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame: CGRectZero
reuseIdentifier: CellIdentifier] autorelease];
UIView *selectionView = [[UIView alloc]initWithFrame:cell.bounds];
[selectionView setBackgroundColor:[UIColor greenColor]];
cell.selectedBackgroundView = selectionView;
[selectionView release];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.