我正在尝试执行类似于此链接 http://www.oracle.com/webfolder/ux/mobile/pattern/img/expand-collpase-description.png 中的操作
单击“更多”按钮时展开 UITextView 内的内容。我正在 viewDidLoad 中创建按钮,如下所示
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"more" forState:UIControlStateNormal];
[self.detailPriceView addSubview:button];
从 PFQuery 加载数据后,我正在 UITextView 内设置按钮的框架
PFQuery *query = [PFQuery queryWithClassName:self.restaurantName];
[query whereKey:@"ItemName" equalTo:self.item_name];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *itemDataObj, NSError *error) {
if (!error) {
self.detailPriceView.text = [itemDataObj objectForKey:@"PriceDetail"];
self.detailPriceView.text = [self.detailPriceView.text substringToIndex:40];
[button setFrame:self.detailPriceView.frame];
}
}];
如何在文本末尾的 UITextView 内添加更多按钮?此外,我还创建了一个约束,以在单击“更多”按钮时增加其高度,但我无法将约束的高度增加到超过某个阈值大小。
最佳答案
我也在做同样的事情。只需将按钮添加到textView.superView即可,因为textView是scrollView。在textView中使用按钮的矩形作为
textView.textContainer.exclusionPaths = [UIBezierPath(矩形:矩形)]
我终于做到了。最重要的是 rect
必须包含在 textView.frame
中。
关于ios - 在 UITextView Objective-C 中的文本末尾添加更多按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33088565/