zoukankan      html  css  js  c++  java
  • UIButton图文上下对齐

    - (void)centerImageAndTitle:(float)spacing

    {

        // get the size of the elements here for readability

        CGSize imageSize = self.imageBtn.imageView.frame.size;

        CGSize titleSize = self.imageBtn.titleLabel.frame.size;

        

        // get the height they will take up as a unit

        CGFloat totalHeight = (imageSize.height + titleSize.height + spacing);

        

        // raise the image and push it right to center it

        self.imageBtn.imageEdgeInsets = UIEdgeInsetsMake(

                                                - (totalHeight - imageSize.height), 0.0, 0.0, - titleSize.width);

        

        // lower the text and push it left to center it

        self.imageBtn.titleEdgeInsets = UIEdgeInsetsMake(

                                                0.0, - imageSize.width, - (totalHeight - titleSize.height), 0.0);

    }

    - (void)centerImageAndTitle

    {

        const int DEFAULT_SPACING = 6.0f;

        [self centerImageAndTitle:DEFAULT_SPACING];

    }

  • 相关阅读:
    23种设计模式彩图
    Win10间歇性卡顿
    RDMA
    mii-tool与ethtool的用法详解
    linux下模拟CPU占用100%小程序
    Linux SNMP 监控一些常用OID
    SNMP协议介绍
    set排序(个人模版)
    TSP(个人模版)
    树的重心(个人模版)
  • 原文地址:https://www.cnblogs.com/jiackyan/p/4431328.html
Copyright © 2011-2022 走看看