Implement a horizontal UIRefreshControl

2019-04-13 20:19发布

How do I go and implement a UIRefreshControl which would get refreshed when pulled from left or right side??

Is it possible with the standard UIRefreshControl? Or is there any API to create this effect? I have been searching a lot to get some lead on this but I am not able to find anything.

All I could find is this answer on SO, but it is written in C# which I am not much familiar with.

2条回答
甜甜的少女心
2楼-- · 2019-04-13 21:02

You could use a UITableViewController that is rotated 90 degrees.

Add [self.view setTransform:CGAffineTransformMakeRotation(-M_PI / 2)]; in the UITableViewController class during setup.

Example using UITableView (and not UITableViewController):

table_ = [[UITableView alloc] initWithFrame:self.bounds];
[table_ setDelegate:self];
[table_ setDataSource:self];
[table_ registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[table_ setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];

UIRefreshControl *ctrl = [[UIRefreshControl alloc] init];
[ctrl setBackgroundColor:[UIColor yellowColor]];
[table_ addSubview:ctrl];

[self addSubview:table_];

Make sure to remember to rotate the content back again in the opposite direction!

查看更多
成全新的幸福
3楼-- · 2019-04-13 21:13

There are no default refreshcontrol for this. You have to create custom refreshcontrol to get this behaviour.

查看更多
登录 后发表回答