Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xib加载view问题 #16

Open
liyuhongWork165 opened this issue Jul 28, 2021 · 3 comments
Open

Xib加载view问题 #16

liyuhongWork165 opened this issue Jul 28, 2021 · 3 comments

Comments

@liyuhongWork165
Copy link

Xib加载view。尺寸超出范围

@liyuhongWork165
Copy link
Author

image

@shmxybfq
Copy link
Owner

xib对象创建好以后需要手动给它设置一下frame,origin的值设为0,宽高设为你实际的宽高就可以了

@wudeliang
Copy link
Collaborator

#pragma mark - Life Cycle Methods

  • (instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
    [self initSelf];
    }
    return self;
    }
  • (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
    [self initSelf];
    }
    return self;
    }

#pragma mark - Tools Methods

#pragma mark - Building SubViews Methods

  • (void)initSelf{
    [[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self.class) owner:self options:nil];
    [self addSubview:self.ContentView];
    [self.ContentView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.mas_equalTo(UIEdgeInsetsZero);
    }];
    }
    可以把xib 的View变成contentView然后直接设置frame 或者动态计算高度。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants