[软件设计/软件工程] 如何为 UIToolbar 上的按钮添加滚动条?

[复制链接]
发表于 2022-5-3 10:23:49
问题
如何向 UIBarButtonItem 按钮添加滚动(在工具栏上放置多个按钮)?

UI工具栏

非常感谢您的帮助!

回答
替换工具栏的superview:
  1. buttonDone = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(buttonDoneDown)];
  2. NSArray *itemsArray = [NSArray arrayWithObjects:buttonDone, nil];

  3. UIScrollView *scrollView = [[UIScrollView alloc] init];
  4. scrollView.frame = toolbar.frame;
  5. scrollView.bounds = toolbar.bounds;
  6. scrollView.autoresizingMask = toolbar.autoresizingMask;
  7. scrollView.showsVerticalScrollIndicator = false;
  8. scrollView.showsHorizontalScrollIndicator = false;
  9. //scrollView.bounces = false;
  10. UIView *superView = toolbar.superview;
  11. [toolbar removeFromSuperview];
  12. toolbar.autoresizingMask = UIViewAutoresizingNone;
  13. toolbar.frame = CGRectMake(0, 0, X, toolbar.frame.size.height);
  14. toolbar.bounds = toolbar.frame;
  15. [toolbar setItems:itemsArray];
  16. scrollView.contentSize = toolbar.frame.size;
  17. [scrollView addSubview:toolbar];
  18. [superView addSubview:scrollView];
复制代码






上一篇:在不执行请求的情况下合并 github.com 上的分支?
下一篇:精简的 Python 生成器,第二更短:如何检索静默使用的元素

使用道具 举报

Archiver|手机版|小黑屋|吾爱开源 |网站地图

Copyright 2011 - 2012 Lnqq.NET.All Rights Reserved( ICP备案粤ICP备14042591号-1粤ICP14042591号 )

关于本站 - 版权申明 - 侵删联系 - Ln Studio! - 广告联系

本站资源来自互联网,仅供用户测试使用,相关版权归原作者所有

快速回复 返回顶部 返回列表