zoukankan      html  css  js  c++  java
  • UIButton(改变Title和image位置)

     UIButton *btn = [[UIButton alloc] init];
        [btn setFrame:frame];
        [btn setTitleColor:titleColor forState:UIControlStateNormal];
        [btn setTitle:title forState:UIControlStateNormal];
        [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        [btn setImage:normalI forState:UIControlStateNormal];
      //按钮内容对齐方式
         btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
       //按钮image位置
     btn.imageEdgeInsets = UIEdgeInsetsMake(0,btn.titleLabel.bounds.size.width, 0,-btn.titleLabel.bounds.size.width);
        //按钮title的位置
        btn.titleEdgeInsets = UIEdgeInsetsMake(0,-btn.imageView.image.size.width, 0, btn.imageView.image.size.width);
      //按钮图片自适应
         btn.imageView.contentMode= UIViewContentModeScaleAspectFit;
    
            
    
    将来的自己,会感谢现在不放弃的自己!
  • 相关阅读:
    gRPC初识
    Go操作MySQL
    Go语言操作Redis
    Markdown 教程
    Go操作MongoDB
    Go操作NSQ
    Go操作kafka
    Go操作etcd
    Go语言获取系统性能数据gopsutil库
    influxDB
  • 原文地址:https://www.cnblogs.com/TheYouth/p/4995911.html
Copyright © 2011-2022 走看看