zoukankan      html  css  js  c++  java
  • iOS CGRectGetMaxX/Y 使用

    在iOS的界面布局中我们可以使用CGRectGetMaxX 这个方法来方便的获取当前控件的x坐标值+宽度的数值,这样便可以方便布局。
    同理CGRectGetMaxY是获取y坐标值+控件高度的值,当然这个系列的方法还有很多大家可以试下。
    [objc] view plaincopyprint?
    /* Return the leftmost x-value of `rect'. */

    CG_EXTERN CGFloat CGRectGetMinX(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the midpoint x-value of `rect'. */

    CG_EXTERN CGFloat CGRectGetMidX(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the rightmost x-value of `rect'. */

    CG_EXTERN CGFloat CGRectGetMaxX(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the bottommost y-value of `rect'. */

    CG_EXTERN CGFloat CGRectGetMinY(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the midpoint y-value of `rect'. */

    CG_EXTERN CGFloat CGRectGetMidY(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the topmost y-value of `rect'. */

    CG_EXTERN CGFloat CGRectGetMaxY(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the width of `rect'. */

    CG_EXTERN CGFloat CGRectGetWidth(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    /* Return the height of `rect'. */

    CG_EXTERN CGFloat CGRectGetHeight(CGRect rect)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    示例代码 演示获取图片的宽度,然后文字加在右边10像素的位置

     _textlabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_imageView.frame)+10, 10, size.width - 100, 80)];
    
    On the road。。。
  • 相关阅读:
    PHP安装linux
    nginx 安装
    Redis安装
    linux启动http服务
    收藏的有用的网页
    laravel框架部署后有用命令
    .net 报错access to the path c: empimagefilesmsc_cntr_0.txt is denied
    oracle 触发器
    学习Auxre记录
    mysql数据库索引
  • 原文地址:https://www.cnblogs.com/ianhao/p/4548172.html
Copyright © 2011-2022 走看看