问题
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