美文网首页
如何使用frame布局

如何使用frame布局

作者: tuyw | 来源:发表于2020-10-21 17:04 被阅读0次

1、子视图相对父视图居中

CGFloat superWidth = 375;
CGFloat superHeight = 667;
self.button.frame = CGRectMake((self.superWidth-50)/2, (self.superHeight-30)/2, 50, 30);

2、子视图相对于另一子视图水平居中

CGFloat midY = CGRectGetMidY(self.targetView.frame);
self.button.frame = CGRectMake(0, midY-30/2, 50, 30);

相关文章

  • 如何使用frame布局

    1、子视图相对父视图居中 2、子视图相对于另一子视图水平居中

  • UIView 的 drawRect方法的使用

    总结来说,当使用frame布局直接设置frame时,drawRect不会触发,但是当使用autoLayout时候,...

  • macOS 开发之- View 的布局方式

    同iOS 开发的布局方式一样,Mac 开发可以使用frame 布局,相对布局。但是在iOS 系统中,frame 的...

  • 使用Masonry无法获取frame值的问题

    在使用Masonry布局,获取控件的frame值的时候,获取的frame都是frame = (0 0; 0 0);...

  • Masonry Frame

    Masonry 和 Frame 使用masonry布局时 不会创建frame 解决方法: 添加 - layoutI...

  • AutoLayout学习

    iOS布局方式的演变 使用Rect的frame布局方式 autoresizingMask方式 AutoLayout...

  • AutoLayout 提前完成布局

    习惯使用AutoLayout进行布局后, 一点都不想再使用frame了.使用AutoLayout的布局时, 默认所...

  • tkinker组件Frame

    Frame 框架控件,作用:作为一种容器,可以把其他空间放在frame上。 使用Frame控件进行布局的话,比较灵...

  • UITabView中tableHeaderView和tableF

    tableHeaderView 在使用frame布局完成后使用mansory 来相对布局操作界面时就会出现 错误的...

  • iOS自动布局

    使用自动布局的步骤是: 1、使用代码自动布局(autolayout) frame就会失效,所以 不需要再去设置视...

网友评论

      本文标题:如何使用frame布局

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