Search code examples
iosios6uirefreshcontrol

Offsetting UIRefreshControl


I am currently using a JASidePanel for my application and I have a UITableViewcontroller with a UIRefreshControl as one of the ViewControllers for it. The width of my tableview still has a width of 320 pixels so the UIRefreshControl gets centered right in the middle of the view. I'm trying to figure out if there's a way to offset the UIRefreshControl (moving the x by 20 pixels to the left) so that it looks centered when I have my side panel visible.

Thanks! JASidePanel


Solution

  • You need to set the frame of the UIRefreshControl. Use this code

    UIRefreshControl *refContr=[[UIRefreshControl alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
    [refContr setTintColor:[UIColor blueColor]];
    [refContr setBackgroundColor:[UIColor greenColor]];
    
    [stocktable addSubview:refContr];
    [refContr setAutoresizingMask:(UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleLeftMargin)];
    
    [[refContr.subviews objectAtIndex:0] setFrame:CGRectMake(30, 0, 20, 30)];
    
    
    NSLog(@"subViews %@",refContr.subviews); 
    

    Output:
    Output