52ky 发表于 2022-5-3 10:23:49

如何为 UIToolbar 上的按钮添加滚动条?

问题
如何向 UIBarButtonItem 按钮添加滚动(在工具栏上放置多个按钮)?

UI工具栏

非常感谢您的帮助!

回答
替换工具栏的superview:
buttonDone = [ initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(buttonDoneDown)];
NSArray *itemsArray = ;

UIScrollView *scrollView = [ init];
scrollView.frame = toolbar.frame;
scrollView.bounds = toolbar.bounds;
scrollView.autoresizingMask = toolbar.autoresizingMask;
scrollView.showsVerticalScrollIndicator = false;
scrollView.showsHorizontalScrollIndicator = false;
//scrollView.bounces = false;
UIView *superView = toolbar.superview;
;
toolbar.autoresizingMask = UIViewAutoresizingNone;
toolbar.frame = CGRectMake(0, 0, X, toolbar.frame.size.height);
toolbar.bounds = toolbar.frame;
;
scrollView.contentSize = toolbar.frame.size;
;
;



页: [1]
查看完整版本: 如何为 UIToolbar 上的按钮添加滚动条?