Giter VIP home page Giter VIP logo

Comments (8)

xjh093 avatar xjh093 commented on July 19, 2024

UIView *view = [[UIView alloc] init];
view 连尺寸都没有,也没有设置约束。

from mylinearlayout.

PaulPaulBoBo avatar PaulPaulBoBo commented on July 19, 2024

view的尺寸随内部元素大小变动,由内部视图约束撑开

from mylinearlayout.

youngsoft avatar youngsoft commented on July 19, 2024

MyLayout对普通视图的自适应是感觉不出来的,所以造成了你的view没有尺寸。问题是你既然已经把view当做一个容器来包装imageview和label。那么为什么不将view改为一个水平先行布局呢?代码还会少很多。

from mylinearlayout.

PaulPaulBoBo avatar PaulPaulBoBo commented on July 19, 2024

首先,感谢您的建议。但view内的样式不固定,这里只是举了个例子,例子里图片和标签是水平左右分布,但实际开发时view内的样式并不是这样. @youngsoft

from mylinearlayout.

youngsoft avatar youngsoft commented on July 19, 2024

因为mylayout内部是用frame来实现的,所以在布局开始时如果是非布局子视图,用的不是mylayout的约束,而是用的autolayout约束的话,可能不会生效。除非autolayout约束设置完后其中的frame计算生效才可能有效。

from mylinearlayout.

aiqinxuancai avatar aiqinxuancai commented on July 19, 2024

使用mas确实是不行,我也是尝试过用mas撑开一个包含UILabel和Image的UIView,但是展示出来怎么都是0x0的尺寸,而对view直接mas的话,又会让linearView的布局不正确,后来使用了MyLinearLayout横纵叠加的方式并整体设置:wrapContentWidth = YES; wrapContentHeight = YES;来实现布局

from mylinearlayout.

PaulPaulBoBo avatar PaulPaulBoBo commented on July 19, 2024

@aiqinxuancai 你说的“MyLinearLayout横纵叠加的方式”能详细点吗?是跟 “youngsoft” 描述的一致吗?“将view改为一个水平先行布局”

from mylinearlayout.

aiqinxuancai avatar aiqinxuancai commented on July 19, 2024

image
就是子view的叠加,横的MyLinearLayout里面放纵的MyLinearLayout

from mylinearlayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.