import "WXZButton.h"
@implementation WXZButton
- (void)layoutSubviews
{
[super layoutSubviews];
// NSLog(@"%@", NSStringFromCGRect(self.frame));
//尺寸
// CGRect frame = self.frame;
// 图片
UIImageView *imageView = self.imageView;
// label
UILabel *titleLabel = self.titleLabel;
//imageView 和titleLabel的位置
// scale 通过scale 来 确定 image 和 label 位置
CGFloat imageViewYScale = 31 / 82.0;
CGFloat titleLabelYScale = (82 - 18) / 82.0;
CGPoint center = imageView.center;
center.x = self.width / 2;
center.y = self.height * imageViewYScale;
imageView.center = center;
// NSLog(@"image%@", NSStringFromCGPoint(center));
center = titleLabel.center;
center.x = self.width / 2;
center.y = self.height * titleLabelYScale;
titleLabel.center = center;
// NSLog(@"title%@", NSStringFromCGPoint(center));
// titleLabel的尺寸
titleLabel.width = self.width;
titleLabel.textAlignment = NSTextAlignmentCenter;
}
@end
网友评论