开发者

Add UILabel above UISearchBar and UITableView like WhatsApp Contacts

开发者 https://www.devze.com 2023-03-13 21:13 出处:网络
I have UISearchBar on UITableView\'s header, I want to add UILabel above UISearchBar. UILabel is hidden for the first time, when User scroll down the TableView, UILabel will开发者_运维技巧 appear. It\

I have UISearchBar on UITableView's header, I want to add UILabel above UISearchBar. UILabel is hidden for the first time, when User scroll down the TableView, UILabel will开发者_运维技巧 appear. It's done in WhatsApp, in the Contacts' tab.

What is the best way to do this?? Any help will be appreciated.

Regards


One way is to add the UILabel, UISearchBar and UITableView in a UIView.

Otherwise, add the UILabel in first row, search bar in the second row and go on...


Not able to test this right now but I think:

 theHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0 - HEADER_HEIGHT, 320, HEADER_HEIGHT)]

 headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, HEADER_HEIGHT)];
 headerLabel.textAlignment = UITextAlignmentCenter;

Also don't forget to add the subview to the header: [theHeader addSubview:headerLabel] and to put a height for your header either within CGRectMake or defined (e.g. #define HEADER_HEIGHT 52.0f)

Let me know if it worked!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号