美文网首页
慎用return

慎用return

作者: imzhuzx | 来源:发表于2020-07-02 22:55 被阅读0次

又写了一个傻逼的bug,底下closeButton一直不出来,想俩小时没想明白,看明白之后彻底无语。是不是因为屏幕高度不够啊,一直没看到这有个return

for (int i = 0; i < count1; i ++) {
    if (i == 4) {
        return;
    }
    UIButton *bgButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [whiteBgView addSubview:bgButton];
    bgButton.frame = CGRectMake(friendEdge + (friendWidth + weEdge)*i, lineView2.bottom + 15, friendWidth, friendHeight);
    
    NSString *imageName = [NSString stringWithFormat:@"lk_share2_%d", i];
    
    UIImageView *avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, friendWidth, friendWidth)];
    avatarImageView.image = [UIImage imageNamed:imageName];
    //        avatarImageView.clipsToBounds = YES;
    //        avatarImageView.layer.cornerRadius = friendWidth/2;
    [bgButton addSubview:avatarImageView];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(-10, avatarImageView.bottom + 10, bgButton.width+20, 12)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = title2Array[i];
    titleLabel.font = [UIFont addMyFont:@"PingFangSC-Regular" size:12];
    titleLabel.textColor = [UIColor colorWithHexString:@"#5F6168"];
    [bgButton addSubview:titleLabel];
}

UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.frame = CGRectMake(0, whiteBgView.height-12-47, whiteBgView.width, 47);
[closeButton setBackgroundColor:[UIColor colorWithHexString:@"#F4F5F9"]];
[closeButton setTitle:@"取消" forState:UIControlStateNormal];
[closeButton setTitleColor:[UIColor colorWithHexString:@"#2B3346"] forState:UIControlStateNormal];
closeButton.titleLabel.font = [UIFont addMyFont:@"PingFangSC-Medium" size:14];
[closeButton addTarget:self action:@selector(doCloseButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[whiteBgView addSubview:closeButton];

相关文章

网友评论

      本文标题:慎用return

      本文链接:https://www.haomeiwen.com/subject/mbgdqktx.html