Title for selected segment in UISegmentedControl disappears when taking a screenshot programmatically

前端 未结 1 1578
生来不讨喜
生来不讨喜 2020-12-20 04:10

I have a UISegmentedControl added to a UIToolbar:

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
toolbar.barS         


        
相关标签:
1条回答
  • 2020-12-20 05:16

    I've replaced

    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    

    With

    [self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES];
    

    And now it works as expected. Still don't understand why that happens though.

    Note that drawViewHierarchyInRect:afterScreenUpdates: is iOS 7 only.

    0 讨论(0)
提交回复
热议问题