#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 = ;
self.imageView.y = ;
self.imageView.width = self.width;
self.imageView.height = self.imageView.width; // 调整文字
self.titleLabel.x = ;
self.titleLabel.y = self.imageView.height;
self.titleLabel.width = self.width;
self.titleLabel.height = self.height - self.titleLabel.y;
} @end