iphone - Unable to programmatically add an image of the right size to UIBarButtonItem -
i having terrible time trying utilize images instead of titles uibarbuttonitems. under understanding setting image uibarbuttonitem automatically scales image right size uibarbuttonitem. create sense, there doesn't seem way resize image (you can't set imageview, or add together subview, or anything). when utilize 2 different images of exact same dimensions (24x24), different results:
myaddbutton = [[uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"plus.png"] style:uibarbuttonsystemitemadd target:self action:@selector(addbuttontapped)]; self.navigationitem.rightbarbuttonitem = myaddbutton; myleftbutton = [[uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"gear.png"] style:uibarbuttonsystemitemadd target:self action:@selector(settingsbuttontapped)]; self.navigationitem.leftbarbuttonitem = myleftbutton;
leads following:
again, gear.png , plus.png same size, 24x24. have confirmed in photoshop.
now if take exact same lines of code, replace gear plus:
myaddbutton = [[uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"plus.png"] style:uibarbuttonsystemitemadd target:self action:@selector(addbuttontapped)]; self.navigationitem.rightbarbuttonitem = myaddbutton; myleftbutton = [[uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@"plus.png"] style:uibarbuttonsystemitemadd target:self action:@selector(settingsbuttontapped)]; self.navigationitem.leftbarbuttonitem = myleftbutton;
i this:
the difference in color beingness due 1 beingness enabled , other not.
i create them uibuttons, utilize imageviews , manually set myself, except background using uibarbuttonitem gives me, , don't want recreate in photoshop.
any ideas what's happening here, , how can prepare it?
thanks in advance.
edit:
turns out issue caused because needed clear build , delete app off of simulator, pulling 48x48 image had used earlier.
make sure have right image in project. and, yeah, seek cleaning project sometimes. removing app device/simulator can helpful.
iphone ios objective-c
No comments:
Post a Comment