iOS 自定義返回按鈕錯位問題(備忘)
阿新 • • 發佈:2019-02-01
UIButton *button1 = [FGWButtoncreatButtonWithtarget:selfsel:@selector(press)];
UIBarButtonItem *leftButon = [[UIBarButtonItemalloc] initWithCustomView :button1];
UIBarButtonItem *fixedButton = [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpacetarget:nilaction:nil];
self
+ (UIButton *)creatButtonWithtarget:(id)target sel:(SEL)sel {
UIButton *button = nil;
//建立圖片按鈕
button = [UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 40, 40);
[button setImage:[UIImageimageNamed
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[button addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
return button;
}