vlasov / CCBottomRefreshControl

MIT License
319 stars 77 forks source link

BottomRefreshControl attributedTitle is transposed across x axis (upside down and aligned on the top) #2

Closed peterjkirby closed 9 years ago

peterjkirby commented 10 years ago

I have a a bottomRefreshControl setup as follows:

UIRefreshControl *refreshControl = [UIRefreshControl new];
 [refreshControl addTarget:self action:@selector(refresh)          
forControlEvents:UIControlEventValueChanged];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
 self.tableView.bottomRefreshControl = bottomRefreshControl;

The text "Pull to Refresh" is rotation 180 degrees and is also position on the top side of the refresh indicator.

When the following line is added, the problem is sort of fixed (the attributedTitle is correctly positioned, but the refresh indicator is now upside down):

refreshControl.transform = CGAffineTransformMakeRotation(M_PI);

One potentially extreme hack that fixes this is to add a second transformation to the above code, that will apply a second transformation to the refreshControl subview that contains the refresh indicator, as follows:

    refreshControl.transform = CGAffineTransformMakeRotation(M_PI);
    UIView *bottomRefreshControlIndicator = [[[refreshControl.subviews firstObject] subviews] firstObject];
    bottomRefreshControlIndicator.transform = CGAffineTransformMakeRotation(M_PI);

This will fix the position and orientation of the refreshControl's attributedTitle, keep it's positioning correct relative to the table view, and keep the indicator in the appropriate orientation.

I don't recommend using the above code, however, unless it is known for certain that the UIRefreshControl view won't be changing anytime. There is probably also a better way of searching through the UIRefreshControl's subviews. The above code was just my first attempt at figuring out what the inside's of UIRefreshControl looked like.

vlasov commented 10 years ago

Hi, Peter!

Yes, known issue ) One day I’ll fix it ) Now you’d better to leave refresh control title empty..

Nick.

On 03 апр. 2014 г., at 23:02, Peter Kirby notifications@github.com wrote:

I have a a bottomRefreshControl setup as follows:

UIRefreshControl *refreshControl = [UIRefreshControl new]; [refreshControl addTarget:self action:@selector(refresh)
forControlEvents:UIControlEventValueChanged]; refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"]; self.tableView.bottomRefreshControl = bottomRefreshControl; The text "Pull to Refresh" is rotation 180 degrees and is also position on the top side of the refresh indicator.

When the following line is added, the problem is sort of fixed (the attributedTitle is correctly positioned, but the refresh indicator is now upside down). refreshControl.transform = CGAffineTransformMakeRotation(M_PI);

— Reply to this email directly or view it on GitHub.

F1NaL commented 9 years ago

Hello. What about fix ?

vlasov commented 9 years ago

Fixed in version 0.4.4