Make scrollbar always visible on UIScrollView?

后端 未结 4 2142
你的背包
你的背包 2020-11-30 09:50

I need to make a scrollbar always visible on viewDidLoad so that the user can understand that there is content to scroll. I did the following:

[myscrollView          


        
4条回答
  •  伪装坚强ぢ
    2020-11-30 10:22

    I dont know whether this will work or not. But just a hint for you.

    Scrollbar inside the Scrollview is a Imageview. Which is a subview of UIScrollview

    So get the Scrollbar Imageview of the UIscrollview. Then try to set that image property hidden to NO or Change Alpha value

    static const int UIScrollViewHorizontalBarIndexOffset = 0;
    static const int UIScrollViewVerticalBarIndexOffset = 1;
    -(UIImageView *)scrollbarImageViewWithIndex:(int)indexOffset 
    {
        int viewsCount = [[yourScrollview subviews] count];
        UIImageView *scrollBar = [[yourScrollview subviews] objectAtIndex:viewsCount - indexOffset - 1];
        return scrollBar;
    }
    
    -(void) viewDidLoad
    {
        //Some Code
        //Get Scrollbar
        UIImageView *scrollBar = [self scrollbarImageViewWithIndex: UIScrollViewVerticalBarIndexOffset];
    
        //The try setting hidden property/ alpha value
        scrollBar.hidden=NO;
    }
    

    Got reference from here

提交回复
热议问题