添加一个button 等宽与视图的宽度
tryButton = [UIButtonbuttonWithType:UIButtonTypeCustom];
tryButton.frame =CGRectMake(0,self.view.frame.size.height-44,self.view.frame.size.width,44);
// [tryButton setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
[tryButtonsetBackgroundColor:[UIColorredColor]];
[tryButtonaddTarget:selfaction:@selector(tryButtonAction)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:tryButton];
添加在scrollView方法里设置坐标即可
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
tryButton.frame =CGRectMake(0, (self.tableView.frame.size.height - 150) + self.tableView.contentOffset.y , tryButton.frame.size.width,tryButton.frame.size.height);
}
本文介绍如何在iOS应用中创建一个按钮,使其宽度与视图相同,并跟随scrollView滚动。通过设置按钮的位置和大小,实现与屏幕宽度等宽的效果。
514

被折叠的 条评论
为什么被折叠?



