[英]add images to bar button item of toolbar in iphone
我想將圖像添加到工具欄的欄按鈕項目我嘗試使用xib和代碼兩個但圖像顯示為白色補丁可以任何人建議我做錯了什么或我應該采取哪種方式
將按鈕類型設置為自定義。
試試這樣吧
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"myImage.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(blah) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 32, 32)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
祝一切順利。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.