如下所示:
需要实现:把这个“退出当前账号”按钮添加到tablefootview上,设置按钮点击(highlightedstate)时的效果为红色。
问题:在IOS6系统上面的效果,有点击效果。但IOS7系统下面没有点击效果,要长按才有效果;
分析:在ios7下面不论是添加到cell上还是添加到tablefootview/tableheadview.都一样。;
解决方法:设置这样的uitableview属性就可以了:
[setUpTabView setDelaysContentTouches:NO]; //使ios7下面的button有highlight效果;
//以下是按钮的设置;
_tabFootView.frame = CGRectMake(0.f, 0.f, 320.f, KISLOGIN_BUTOTN_HEIGHT);
_tabFootView.backgroundColor = [UIColor clearColor];
// _tabFootView.userInteractionEnabled = NO;
_isLoginBtn.frame = CGRectMake(orginX, 0.f, KISLOGIN_BUTTON_WIDTH, KISLOGIN_BUTOTN_HEIGHT);
_isLoginBtn.layer.borderColor = [UIColor colorWithHexString:@"#cccccc"].CGColor;
_isLoginBtn.layer.borderWidth = 0.7f;
_isLoginBtn.layer.cornerRadius = 5.0f;
[_isLoginBtn setBackgroundColor:[UIColor colorWithHexString:@"#ff3b30"]];
[_isLoginBtn setBackgroundImage:[UIImage imageWithUIView:_isLoginBtn] forState:UIControlStateHighlighted];
_isLoginBtn.backgroundColor = [UIColor colorWithHexString:@"#ffffff"];
// [_isLoginBtn setTintColor:[UIColor yellowColor]];
[_isLoginBtn setTitle:@"退出当前账号" forState:UIControlStateNormal];
[_isLoginBtn setTitleColor:[UIColor colorWithHexString:@"#ff3b30"] forState:UIControlStateNormal];
[_isLoginBtn setTitleColor:[UIColor colorWithHexString:@"ffffff"] forState:UIControlStateHighlighted];
[_isLoginBtn addTarget:self action:@selector(isLoginEventToLogout:) forControlEvents:UIControlEventTouchUpInside];
// [_isLoginBtn addTarget:self action:@selector(isLoginEventHighlight:)forControlEvents:UIControlEventTouchDown];
[_tabFootView addSubview:_isLoginBtn];
[setUpTabView setTableFooterView:_tabFootView];