我正在使用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實例方法,因此您可以將它包含在代碼中,而不必在界面中聲明它。 –