1:获取某一行的坐标
UITableViewCell *cell = [_myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow: inSection:]]; [tipsView setY:CGRectGetMaxY(cell.frame) - 0.5]; - (void)setY:(CGFloat)y{ CGRect frame = self.frame; frame.origin.y = y; self.frame = frame; }
2:设置视图某个角的圆角(这边是左下跟右下)
[self addRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(, )]; [self setClipsToBounds:YES]; - (void)addRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii{ UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:cornerRadii]; CAShapeLayer *maskLayer = [CAShapeLayer new]; maskLayer.frame = self.bounds; maskLayer.path = maskPath.CGPath; self.layer.mask = maskLayer; }
3:设置一个视图弹出来,可以先加载然后隐藏
if (!_inputTipsView) { _inputTipsView = ({ EaseInputTipsView *tipsView = [EaseInputTipsView tipsViewWithType:EaseInputTipsViewTypeLogin]; tipsView.valueStr = nil; __weak typeof(self) weakSelf = self; tipsView.selectedStringBlock = ^(NSString *valueStr){ [weakSelf.view endEditing:YES]; weakSelf.myLogin.email = valueStr; [weakSelf refreshIconUserImage]; [weakSelf.myTableView reloadData]; }; UITableViewCell *cell = [_myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow: inSection:]]; [tipsView setY:CGRectGetMaxY(cell.frame) - 0.5]; [_myTableView addSubview:tipsView]; tipsView; }); } 注意:因为这边输入框是在列表上,所以把要弹出的视图就addSubview到其上面; cell.textField.keyboardType = UIKeyboardTypeEmailAddress; [cell configWithPlaceholder:@" 电子邮箱/个性后缀" andValue:self.myLogin.email]; cell.textValueChangedBlock = ^(NSString *valueStr){ weakSelf.inputTipsView.valueStr = valueStr; weakSelf.inputTipsView.active = YES; weakSelf.myLogin.email = valueStr; [weakSelf.iconUserView setImage:[UIImage imageNamed:@"icon_user_monkey"]]; }; 这样可以通过active属性进行控制它是否显示; 子视图(其实就是一个列表,并给它设置的大小)的这个属性控制: - (void)setActive:(BOOL)active{ _active = active; self.hidden = self.dataList.count <= || !_active; }
4:根据不同的内容加载跟去除视图
-(void)configUI:(BOOL)haveData
{
if (haveData) {
//有数据
if (self.curSearchImageNoDataView) {
[self.curSearchImageNoDataView removeFromSuperview];
self.curSearchImageNoDataView=nil;
} if (!_myTableView) {
_myTableView = [[UITableView alloc] initWithFrame:CGRectMake(,0.5, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
_myTableView.backgroundColor = RGB(, , );
_myTableView.showsVerticalScrollIndicator = NO;
_myTableView.showsHorizontalScrollIndicator=NO;
_myTableView.tableHeaderView=[self addTableHeaderView];
_myTableView.tableFooterView=[self addTableFootView];
_myTableView.dataSource = self;
_myTableView.delegate = self;
_myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[_myTableView registerClass:[ZURoomImageCell class] forCellReuseIdentifier:NSStringFromClass([ZURoomImageCell class])];
_myTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadTableData)]; [self.view addSubview:_myTableView];
[_myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(UIEdgeInsetsMake(0.5, , , ));
}];
} }
else
{
//无数据
if (self.myTableView) {
[self.myTableView removeFromSuperview];
self.myTableView=nil;
} if (!self.curSearchImageNoDataView) {
self.curSearchImageNoDataView=[[ZUSearchImageNoDataView alloc]init];
[self.view addSubview:self.curSearchImageNoDataView];
[self.curSearchImageNoDataView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo();
make.left.and.right.and.bottom.mas_equalTo();
}];
} __weak typeof(self) weakSelf = self;
[self.curSearchImageNoDataView initWithHeightValue:self.rongYunName doneBlock:^{
[weakSelf addRoomImageAction];
}];
}
}