Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

使用Masonry布局问题 #144

Open
Open
@BuddyLiu

Description

@BuddyLiu

子视图为自定义样式,使用Masonry布局,无法展示;demo代码如下:

UIView *view = [[UIView alloc] init];view.backgroundColor = [UIColor grayColor];UIImageView *imageView = [[UIImageView alloc] init];imageView.backgroundColor = [UIColor redColor];imageView.clipsToBounds = YES;imageView.layer.cornerRadius = 8;[view addSubview:imageView];[imageView mas_makeConstraints:^(MASConstraintMaker *make) {    make.left.equalTo(view).offset(5);    make.top.greaterThanOrEqualTo(view).offset(2);    make.centerY.equalTo(view);    make.width.height.equalTo(@16);}];UILabel *label = [[UILabel alloc] init];label.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];label.text = [NSString stringWithFormat:@"  label%d  ", i];label.clipsToBounds = YES;label.layer.cornerRadius = 8;label.layer.borderColor = [UIColor lightGrayColor].CGColor;label.layer.borderWidth = 0.5;[view addSubview:label];[label mas_makeConstraints:^(MASConstraintMaker *make) {    make.left.equalTo(imageView.mas_right).offset(5);    make.right.lessThanOrEqualTo(view).offset(-5);    make.top.greaterThanOrEqualTo(view).offset(8);    make.centerY.equalTo(view);    make.height.greaterThanOrEqualTo(@16);}];[self.flowLayout addSubview:view];-(MyFlowLayout *)flowLayout {    if(_flowLayout == nil) {        _flowLayout = [MyFlowLayout flowLayoutWithOrientation:MyOrientation_Vert arrangedCount:0];        _flowLayout.subviewHSpace = 16; // 子视图之间的水平间距        _flowLayout.subviewVSpace = 8; // 子视图之间的垂直间距        _flowLayout.padding = UIEdgeInsetsMake(5, 5, 5, 5); // 视图四周的内边距值    }    return _flowLayout;}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp