2010-08-06 100 views
-2

沒有在tableview單元格中創建任何uibutton(帶背景圖像的自定義按鈕)。 我想將附件指示器顏色從灰色更改爲橙​​色。我該怎麼辦...如何使UITableViewCellAccessoryDisclosureIndicator以橙色而不是灰色顯示?

plz儘快回覆(PLZ回答我很清楚,否則我無法理解)...

我等待烏爾答覆...

感謝ü...

+0

PLZ儘快回覆我... – Mano 2010-08-06 13:40:41

+0

而不產生的UIButton或作爲的UIImageView你的UITableViewCell的accessoryView的實例,這是不可能的。 – jamapag 2010-08-06 13:57:26

+0

http://stackoverflow.com/questions/3423824/how-do-i-make-uitableviewcellaccessorydisclosureindicator-visible-in-orange-color/3423863#3423863 – Pablo 2010-08-06 15:21:30

回答

5

你需要創建一個內含一個UIImageView一個新的UIView,然後設置,作爲配件爲電池。因此,您需要創建一個像默認配件一樣的圖像,但需要使用您想要的顏色。

UIView* accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 24, 50)]; 
    UIImageView* accessoryViewImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NEWIMAGE.png"]]; 
    accessoryViewImage.center = CGPointMake(12, 25); 
    [accessoryView addSubview:accessoryViewImage]; 
    [cell setAccessoryView:accessoryView]; 
    [accessoryViewImage release]; 
    [accessoryView release]; 
+0

非常感謝你... OCTERMIRCTY – Mano 2010-08-07 06:14:35

7

有一個更容易的解決了這個:

cell.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"theimage.png"]] autorelease]; 
0

對於其他人誰正在就這個問題仍然磕磕絆絆,這裏是如何做到這一點編程。

創建UIView子類,並具有以下覆蓋drawRect:

#define PADDING 4.f //give the canvas some padding so the ends and joints of the lines can be drawn with a mitered joint 

- (void)drawRect:(CGRect)rect 
{ 
    CGContextRef context = UIGraphicsGetCurrentContext(); 

    CGContextSetStrokeColorWithColor(context, [UIColor grayColor].CGColor); 
    CGContextSetLineWidth(context, 3.f); 
    CGContextSetLineJoin(context, kCGLineJoinMiter); 

    CGContextMoveToPoint(context, PADDING, PADDING); 
    CGContextAddLineToPoint(context, self.frame.size.width - PADDING, self.frame.size.height/2); 
    CGContextAddLineToPoint(context, PADDING, self.frame.size.height - PADDING); 

    CGContextStrokePath(context); 
} 

這繪製股票指示箭頭。從這裏你可以改變顏色,線寬等

到指示器視圖添加到您的細胞:

#define ACCESSORY_WIDTH 13.f 
#define ACCESSORY_HEIGHT 18.f 

cell.accessoryView = [[AccessoryIndicatorView alloc] initWithFrame:CGRectMake(self.frame.size.width - ACCESSORY_WIDTH - CELL_PADDING, self.frame.size.height/2 - ACCESSORY_HEIGHT/2, ACCESSORY_WIDTH, ACCESSORY_HEIGHT)]; 
相關問題