How to set content size of UIScrollView dynamically

前端 未结 11 1923
耶瑟儿~
耶瑟儿~ 2020-12-01 05:41

I got question about UIScrollview.

The story is I have a UIView named ChartsView which I re-draw it myself by override method drawRec

11条回答
  •  难免孤独
    2020-12-01 05:56

    One more easy way

    - (void)viewDidLoad
    {
        float sizeOfContent = 0;
        UIView *lLast = [scrollView.subviews lastObject];
        NSInteger wd = lLast.frame.origin.y;
        NSInteger ht = lLast.frame.size.height;
    
        sizeOfContent = wd+ht;
    
        scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, sizeOfContent);
    }
    

提交回复
热议问题