Offsetting UIRefreshControl
Try editing the bounds
. For example, to move the control down +50px:
refreshControl.bounds = CGRectMake(refreshControl.bounds.origin.x, -50, refreshControl.bounds.size.width, refreshControl.bounds.size.height);[refreshControl beginRefreshing];[refreshControl endRefreshing];
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:
I needed to do this in order to move the UIRefreshControl downwards. My solution was to subclass UIRefreshControl, and overwrite the layoutSubviews method to set a CAAffineTransform translation on each subview. Unfortunately you can't just set a transform on the UIRefreshControl.
Change xOffset and yOffset as necessary.
@interface MyUIRefreshControl : UIRefreshControl@end@implementation MyUIRefreshControl- (void)layoutSubviews { [super layoutSubviews]; for (UIView *view in self.subviews) { view.transform = CGAffineTransformMakeTranslation(xOffset, yOffset); }}@end