我正在使用UITextView
,我想删除UITextview
底部的空格。如何删除UITextView底部的空格?
0
A
回答
1
我上面code.try已经更新了它。我有觉得你有欲望的结果..
// Create a size with large height, but matching width to UITextView.
[myTextView setBackgroundColor:[UIColor greenColor]];
CGSize maxSize = CGSizeMake(myTextView.frame.size.width, 20);
// Determine the size needed to display the text - we just need the new height.
CGSize textSize = [myTextView.text sizeWithFont:myTextView.font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap];
// Set the UITextView's frame to the new height.
CGRect textViewRect = myTextView.frame;
textViewRect.size.height = textSize.height+13;
myTextView.frame = textViewRect;
2
是这样的吗?
textView.text = [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
0
我猜想/猜测你想调整一个UITextView很好地容纳文本。如果是的话,我建议你的调查:
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode;
例如:
// Create a size with large height, but matching width to UITextView.
CGSize maxSize = CGSizeMake(myTextView.frame.size.width, 9999);
// Determine the size needed to display the text - we just need the new height.
CGSize textSize = [myTextView.text sizeWithFont:myTextView.font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap];
// Set the UITextView's frame to the new height.
CGRect textViewRect = myTextView.frame;
textViewRect.size.height = textSize.height;
myTextView.frame = textViewRect;
相关问题
- 1. 从UITextView删除底部空间
- 2. 如何删除页面底部顶部e的空格?
- 3. 如何从页脚底部删除空格
- 4. 如何从JTable底部删除多余的空白空间?
- 5. 如何删除桌子底部的空白空间?
- 6. 如何删除RadEditor底部的空白空间
- 7. 删除博客底部的空白处
- 8. 删除屏幕底部的空白Android
- 9. 如何删除我的网页底部的大白空间?
- 10. 如何删除UINavigationBar的边界底部?
- 11. hightcharts - 如何删除底部的框
- 12. 如何删除页面底部的空白(镀铬扩展名)?
- 13. 如何删除HTML页面底部的多余空间?
- 14. 如何删除折叠工具栏的底部空白处?
- 15. 如何从DataGridView控件的底部删除空行?
- 16. 如何删除表格元素中图像底部的边距?
- 17. 如何删除分隔在底部AppBarLayout
- 18. 如何删除底部滚动?
- 19. 表中pdfMake.js和分页符,如何删除底部空行
- 20. 的UITextView与底部填充
- 21. 如何清除跨度顶部/底部的空白空间?
- 22. HTML底部的空格
- 23. 如何删除表格后的空格
- 24. 删除应用程序底部的空白空间
- 25. Android:如何删除编辑文本的底部输入部分和底部空白之间的填充
- 26. 删除空格
- 27. 删除空格
- 28. 删除空格
- 29. 删除空格
- 30. 如何恢复UITextView中删除的tex?
我必须写 - (CGSize)sizeWithFont:(UIFont *)字体constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode; .h文件中的 方法? – PJR
textViewRect.height = textSize.height; 行显示错误 – PJR
不,这是一个NSString实例方法,因此您可以将它包含在代码中,而不必在界面中声明它。 –