Is there a way to put UITextView's scroll indicator to outside UITextView?

夙愿已清 提交于 2020-01-11 02:11:52

问题


It might be a silly question. I'm trying to set left/right margins like the attached picture. I succeeded to implement it by adding UITextView to UIScrollView. However, I could achieve almost everything I want with UITextView alone. For example, with UIScrollView, when I manually change the text of UITextView, it automatically scrolls to bottom regardless of setting its .scrollEnabled to No.

It would be perfect if a scroll indicator of UITextView appears outside UITextView. In the attached picture, let's say the red box represents the entire UITextView. I tried to change UITextView's scrollIndicatorInsets property, but a scroll indicator can be moved only inward to be visible.

Several apps such as Pages, aWriter, Plaintext achieve this feature. Could you give any suggestion?

Thank you!

I


回答1:


You can set the scroller right inset value of the UITextView to negative value and disable the clip subview option to achieve your require. No other scrollview is needed.




回答2:


Alternatively you could set the Right contentInset property.




回答3:


UIEdgeInsets insets =  textView.scrollIndicatorInsets;
insets.right += 5; //add what ever is your margain
textView.scrollIndicatorInsets = insets;


来源:https://stackoverflow.com/questions/4343390/is-there-a-way-to-put-uitextviews-scroll-indicator-to-outside-uitextview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!