Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 966
user754905 Avatar asked Jun 25 '13 23:06

user754905


2 Answers

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]; 
like image 118
user1195202 Avatar answered Sep 20 '22 00:09

user1195202


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

like image 43
Prince Kumar Sharma Avatar answered Sep 22 '22 00:09

Prince Kumar Sharma