我已经在NavigationItem中设置了LeftBarButton。
代码:
UIButton leftBtn = new UIButton();
leftBtn.Frame = new CoreGraphics.CGRect(0, 14, 30, 30);
leftBtn.SetImage(UIImage.FromBundle("cancel_white_icon"), UIControlState.Normal);
leftBtn.TintColor = GargiColor.WhiteColor();
UIBarButtonItem barBtnLeft = new UIBarButtonItem();
barBtnLeft.CustomView = leftBtn;
barBtnLeft.TintColor = GargiColor.WhiteColor();
NavigationItem.SetLeftBarButtonItem(barBtnLeft, true);
编辑:
我的期望:
“取消”按钮在左侧有更多空间。如何将其设置为LeftSide作为后退按钮。
我的要求输出如下:
答案 0 :(得分:1)
var negativeSpace = new UIBarButtonItem (UIBarButtonSystemItem.FixedSpace);
negativeSpacae.Width = -8;
var leftBtn = new UIButton (new RectangleF (0, 0, 25, 25));
leftBtn.SetImage(UIImage.FromBundle("cancel_white_icon"), UIControlState.Normal);
leftBtn.TintColor = GargiColor.WhiteColor();
UIBarButtonItem [] bArray = {
negativeSpace, new UIBarButtonItem (leftBtn)
};
NavigationItem.SetLeftBarButtonItems (bArray, true);