ios - Image color in UIButton gets masked to background color -
i have uibutton
, should have white image , blue background. problem is, color of image gets masked background color , becomes white blue. this how should , this (ignore difference in background color). here's code set image:
- (uibutton *)navbutton { if (_navbutton == nil) { uibutton *navbutton = [uibutton buttonwithtype:uibuttontypecustom]; navbutton.translatesautoresizingmaskintoconstraints = no; [navbutton setbackgroundcolor:[uicolor appblue]]; [navbutton setimage: [uiimage imagenamed:@"car_icon"] forstate:uicontrolstatenormal]; [navbutton setenabled:no]; _navbutton = navbutton; } return _navbutton; }
you can use this
uiimage *image = [[uiimage imagenamed:@"car_icon"] imagewithrenderingmode:uiimagerenderingmodealwaystemplate]; [button setimage:image forstate:uicontrolstatenormal];
Comments
Post a Comment