English 中文(简体)
航行条图
原标题:navigation bar image hiding custom navigation bar button

我能够给航道打上形象,并改变航条星子项目的形象。 出于某种原因,导航条形图像,即gues,与导航条形图相重叠。 航行驳船纽扣在左边的航标图上,但并未显示航标形象,因此运行正确。 此处为法典;

UIImage *imagebar = [UIImage imageNamed: @"schedule-strip.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: imagebar];
imageView.frame = CGRectMake(0, 0, 190, 44);
imageView.contentMode = UIViewContentModeScaleAspectFill;
self.navigationItem.titleView = imageView;


UIImage* image = [UIImage imageNamed:@"back-icon.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton* someButton = [[UIButton alloc] initWithFrame:frame];
[someButton setBackgroundImage:image forState:UIControlStateNormal];
[someButton setShowsTouchWhenHighlighted:YES];
[someButton addTarget:self action:@selector(backToMore) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* someBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:someButton];
[self.navigationItem setLeftBarButtonItem:someBarButtonItem];

[someBarButtonItem release];
[someButton release]; 

帮助我。

最佳回答

use the code [imageView addsubView someButton];

我希望现在就看到纽州。 实际上,你正在把左条 bar子添加到停泊的航道上,并且作为制造一些布道的乌普车,并没有在座标上添加,而图像座标与你的航条相重叠。 因此,通过点击该地区,它正在工作,但纽州并不明显。

问题回答
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"TopBg.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

延伸@interface MyTool Bar :UIToolbar,并在MyTool Bar成为目标之后,使你成为通航的温带。 享有

Ketan did you check for image ? is image exist in your project? Why you are using frame and content mode property for Navigation bar title ? May this link Help you

http://iosdevperteloips.com/user-interface/ios-5-customize-uinavigationbar-and-uibarbuttonitem-with-appearance-api.html>





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签