2017-12-24 26 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]];