下图:类似于Notes应用程序的UI搜索栏-iPhone
Notes应用程序使用一张破烂纸张的小图像来暗示之前撕破的页面。 我试图用以下方式复制这种行为,但我的问题是,搜索栏不再处于活动状态下图:类似于Notes应用程序的UI搜索栏-iPhone,iphone,uiimageview,uisearchbar,Iphone,Uiimageview,Uisearchbar,Notes应用程序使用一张破烂纸张的小图像来暗示之前撕破的页面。 我试图用以下方式复制这种行为,但我的问题是,搜索栏不再处于活动状态 //mySearchBar and raggedPaper are instance variables mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,320,44)]; mySearchBar.delegate = self; [mySearchBar sizeToFit];
//mySearchBar and raggedPaper are instance variables
mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,320,44)];
mySearchBar.delegate = self;
[mySearchBar sizeToFit];
raggedPaper = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"raggedpaper.png"]];
[raggedPaper addSubView:mySearchBar];
self.tableView.tableHeaderView = raggedPaper;
看起来一切正常,但搜索栏不再激活。您尝试过以下方法吗:
//mySearchBar and raggedPaper are instance variables
mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0,320,44)];
mySearchBar.delegate = self;
[mySearchBar sizeToFit];
raggedPaper = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"raggedpaper.png"]];
[raggedPaper addSubView:mySearchBar];
self.tableView.tableHeaderView = raggedPaper;
raggedPaper.userInteractionEnabled = YES
或者,如果它不起作用,您可以用另一种方法:将粗糙的纸张图像添加到搜索栏,其clipsToBounds设置为NO.userInteractionEnabled起作用!这听起来很合乎逻辑,谢谢。