zoukankan      html  css  js  c++  java
  • IOS客户端Coding项目记录(六)

    1:获取某一行的坐标

    UITableViewCell *cell = [_myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    
    [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(2, 2)];
    
     [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:0 inSection:0]];
    
                [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 <= 0 || !_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,0.5, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
                _myTableView.backgroundColor = RGB(242, 242, 242);
                _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, 0, 0, 0));
                }];
            }
            
        }
        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(0);
                    make.left.and.right.and.bottom.mas_equalTo(0);
                }];
            }
            
            __weak typeof(self) weakSelf = self;
            [self.curSearchImageNoDataView initWithHeightValue:self.rongYunName doneBlock:^{
                [weakSelf addRoomImageAction];
            }];
        }
    }
  • 相关阅读:
    漂亮的自适应宽度的多色彩CSS图片按钮
    Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
    QT的父子Widget之间消息的传递(如果子类没有accept或ignore该事件,则该事件会被传递给其父亲——Qlabel与QPushButton的处理就不一样)
    QT内置的ICON资源
    QT事件过滤器(QT事件处理的5个层次:自己覆盖或过滤,父窗口过滤,Application过滤与通知)
    QMetaObject感觉跟Delphi的类之类有一拼,好好学一下
    POJ 1013 小水题 暴力模拟
    WMDestroy函数调用inherited,难道是为了调用子类覆盖函数?还有这样调用的?
    技术资深、还关注市场的几率较高
    有感,懂市场比懂产品重要,懂产品比懂技术重要——想起凡客诚品和YY语音了
  • 原文地址:https://www.cnblogs.com/wujy/p/5444045.html
Copyright © 2011-2022 走看看