简体   繁体   中英

UINavigationBarItem custom - how to get the corner of tabcontroller?

i want to ask how i can get the icon of navigationtabbaritem to the left corner (left:0) and right corner (right:0).

my code :

_custombtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
_custombtn.backgroundColor = [UIColor redColor];
[_custombtn setBackgroundImage:[UIImage imageNamed:@"ic_msg.png"]forState:UIControlStateNormal];
[_custombtn addTarget:self action:@selector(viewBn:) forControlEvents:UIControlEventTouchUpInside];
self.csbtn = [[UIBarButtonItem alloc]initWithCustomView:_custombtn];

导航项

UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];    
aButton.frame = CGRectMake(0.0, 0.0, 44, 44);
UIBarButtonItem *aBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aButton];
[aButton addTarget:self action:@selector(rightBarButtonAction:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *spaceFix = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
spaceFix.width = -10;

self.navigationItem.rightBarButtonItems = @[spaceFix, aBarButtonItem];

Please add spaceFix for resolve your problem may this help lot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM