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!
You need to set the frame of the
UIRefreshControl
. Use this codeOutput:
For Swift 2.2 solution is
Thats it.
Try editing the
bounds
. For example, to move the control down +50px:Here's a Swift version similar to the workaround that Werewolf suggested. I'm using my own custom activity view class (
MyCustomActivityIndicatorView
) and it's also a subview of the refresh control, so I make sure I don't mess with it's frame, just the frame of the default subviews. After callinglayoutSubviews
on super I adjust the custom activity view's frame to match. This is all contained in a customUIRefreshControl
subclass.Note: I'm adding in UIView's layout margins in which isn't strictly necessary but gives my activity indicator some space to breath.
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.