問題の追加メッセージを伝えるイメージにはツールバーを使用UIBarButtonItem、表示空白ホワイトボックスの代わりに画像
-
26-09-2019 - |
質問
Imなどimう間違っています。ファイル名が正しいこと確認してください、スタイルの設定です。がー銀行の白いボックスのサイズのイメージです。Im用UINavigationController.
はい、ありがとうよろしくお願いします。
**参考までに私新お疲新しい目的地であるように硬くっています。;)
UIBarButtonItem *toolbarChannelGuideButton = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"channel-guide-button.png"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(action:)];
self.toolbarItems = [NSArray arrayWithObjects:toolbarChannelGuideButton, nil];
[toolbarChannelGuideButton release];
解決
の理由で、白いマスクをしたので UIToolBar
のだめカラー画像としてデフォルトです。のそのためには作成 UIImage
その割り当て UIButton
そのイメージです。その作成 UIBarButton
を使用 initWithCustomView
の UIButton
としてのカスタムビュー。
コード:
//Load the image
UIImage *buttonImage = [UIImage imageNamed:@"your-image.png"];
//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
//sets the frame of the button to the size of the image
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
//creates a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.toolbarItems = [NSArray arrayWithObjects:customBarItem, nil];
[customBarItem release];
他のヒント
あなたは下に使用することができるのiOS 7以降で
UIImage *image = [[UIImage imageNamed:@"myImage.png"];
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(YOUR_METHOD:)];
んチャンネルガイド - button.pngプロジェクトに属し?
あなたはこのように、このアウトを破ることができます:
UIImage *image = [UIImage imageNamed:@"channel-guide-button.png"];
NSLog(@" image = %p", image);
UIBarButtonItem *toolbarChannelGuideButton = [[UIBarButtonItem alloc]
initWithImage:image
style:UIBarButtonItemStylePlain
target:self
action:@selector(action:)];
またはちょうどあなたのプロジェクトをチェック; - )
所属していません StackOverflow