问题
如何向 UIBarButtonItem 按钮添加滚动(在工具栏上放置多个按钮)?
UI工具栏
非常感谢您的帮助!
回答
替换工具栏的superview:
- buttonDone = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(buttonDoneDown)];
- NSArray *itemsArray = [NSArray arrayWithObjects:buttonDone, nil];
- UIScrollView *scrollView = [[UIScrollView alloc] 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 removeFromSuperview];
- toolbar.autoresizingMask = UIViewAutoresizingNone;
- toolbar.frame = CGRectMake(0, 0, X, toolbar.frame.size.height);
- toolbar.bounds = toolbar.frame;
- [toolbar setItems:itemsArray];
- scrollView.contentSize = toolbar.frame.size;
- [scrollView addSubview:toolbar];
- [superView addSubview:scrollView];
复制代码
|