按钮的蓝色图像

时间:2015-04-23 14:14:31

标签: ios objective-c uibutton

我的costoum单元格中有按钮,我正在设置代码中的图像。但是发生了一些奇怪的事情。我的图片是蓝色的。

 BOOL isTheObjectThere = [self.favoriteArry containsObject:self.tableData[indexPath.row]];
        if (isTheObjectThere==TRUE) {
            cell.favBtn.hidden = NO;
            [cell.favBtn setImage:[UIImage imageNamed:@"favorite_star.png"] forState:UIControlStateNormal];
            cell.favBtn.tag = indexPath.row;
            [cell.favBtn addTarget:self action:@selector(unfavoriteBtn:) forControlEvents:UIControlEventTouchUpInside];

enter image description here

1 个答案:

答案 0 :(得分:0)

如评论中所述,您应该创建具有UIButtonTypeCustom类型的按钮,以防它当前设置为UIButtonTypeSystem,并且您希望避免使用色调颜色。或者,您可以设置图像渲染模式,以确保始终获得原始图像而不是有色图像:

^            # beggining of line
(?=          # positive lookahead (true if pattern present after current position; in this case the beginning of current line)
  .*         # anything before the pattern we search for
  (?:color|background-color|background-image)\:      # match any of those 3 sequences followed by : char
  .*?;       # anything followed by ; but not looking beyond the first ; found
  )
.*           # match the rest of the chars from where the (?= ) was found.
/gmx         # MODIFIERS: global, multi-line, extended (for comments, ignores spaces and anything after #)