2017-12-24 10 views
0

、このコードが動作しているtintColorをUIButtonに保持する方法は?このようなUIButtonのUIImageViewにtintColorを設定私は

UIImage* img = [UIImage imageNamed:imageName]; 
icon.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 
icon.tintColor = [UIColor greenColor]; 

が、その後UIButton、UIImageの初期の色に色のリターンをクリックしてください。

緑の色を維持するにはどうすればいいですか?

ありがとうございます!

+1

の可能性のある重複した[なぜUIButton.tintColorが動作しない?](https://stackoverflow.com/questions/11066008/why-is-my-uibutton-tintcolor-not-working) – Daniel

答えて

1

助けがあれば、このようにお試しください。

UIImage *image = [[UIImage imageNamed:@“imageName.png”] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 
     [_yourBtn setImage:image forState:UIControlStateNormal]; 
     [_yourBtn setTintColor:[UIColor greenColor]]; 
関連する問題