【发布时间】:2017-02-13 10:51:24
【问题描述】:
如何在顶部创建一个水平滚动视图,例如具有许多按钮的滚动菜单(例如:20 个按钮)? 请帮忙!
我正在使用以下代码:
CGRect buttonFrame = CGRectMake(0.0f, 0.0f, scrollView.frame.size.width, scrollView.frame.size.height);
for (NSString *text in wordsArray) {
UIButton *button = [[UIButton alloc]initWithFrame:buttonFrame];
button.text = text;
[scrollView addSubview:button];
buttonFrame.origin.x +=buttonFrame.size.width;
}
CGSize contentSize = scrollView.frame.size;
contentSize.width = buttonFrame.origin.x;
scrollView.contentSize = contentSize;
但没有得到我想要的。
【问题讨论】:
-
请检查这个答案,我认为这是你要找的答案stackoverflow.com/questions/6688160/…
标签: ios objective-c uiscrollview uibutton