watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveWFuZ3poZW4xOTkwMDcwMQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

IOS:

UIBarButtonItem * searchBtnItem = [[UIBarButtonItem alloc]initWithCustomView:_searchButton];

UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
/**
* width为负数时。相当于btn向右移动width数值个像素,因为button本身和边界间距为5pix,所以width设为-5时。间距正好调整
* 为0。width为正数时。正好相反,相当于往左移动width数值个像素
*/
negativeSpacer.width = -16;
self.navigationItem.rightBarButtonItems= [NSArray arrayWithObjects:negativeSpacer,searchBtnItem, nil];

SWIFT:

UIBarButtonItem 小记边-LMLPHP

版权声明:本文博客原创文章,博客,未经同意,不得转载。

04-28 05:48