zoukankan      html  css  js  c++  java
  • iOS 自定义图片和文字垂直显示按钮<上面是图片,文字显示下面>

    #import <UIKit/UIKit.h>
    
    @interface VerticalButton : UIButton
    
    @end
    #import "VerticalButton.h"
    
    @implementation VerticalButton
    
    - (void)setup
    {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    - (instancetype)initWithFrame:(CGRect)frame
    {
        if (self = [super initWithFrame:frame]) {
            [self setup];
        }
        return self;
    }
    
    - (void)awakeFromNib
    {
        [self setup];
    }
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        
        // 调整图片
        self.imageView.x = 0;
        self.imageView.y = 0;
        self.imageView.width = self.width;
        self.imageView.height = self.imageView.width;
        
        // 调整文字
        self.titleLabel.x = 0;
        self.titleLabel.y = self.imageView.height;
        self.titleLabel.width = self.width;
        self.titleLabel.height = self.height - self.titleLabel.y;
    }
    
    @end
  • 相关阅读:
    基于nginx结合openssl实现https
    更新续约与重新登陆
    DNS服务器
    ELK日志分析系统。
    OpenSSH远程控制
    DHCP配置
    DHCP服务概述
    网络服务
    磁盘配额
    磁盘配额
  • 原文地址:https://www.cnblogs.com/HJiang/p/5991244.html
Copyright © 2011-2022 走看看