UIButton 解耦

20161110

继续解耦,

//DENG
    CGRect theFrame = cell.nickNameLabel.frame;
    theFrame.origin.y = 18;
    cell.nickNameLabel.frame = theFrame;
    return cell;




http://blog.sina.com.cn/s/blog_a573f7990101cdpe.html

UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout







见过的 最漂亮 的一次 解耦:

2016 10 28



import <UIKit/UIKit.h>

@interface FSVerticalRankImageTitleButton : UIButton
@property (nonatomic, assign)CGFloat imageCenterY;
@property (nonatomic, assign)CGFloat titleOriginY;
@end



import "FSVerticalRankImageTitleButton.h"

@implementation FSVerticalRankImageTitleButton

-(void)layoutSubviews {
[super layoutSubviews];

// Center image
CGPoint center = self.imageView.center;
center.x = self.frame.size.width/2;
center.y =_imageCenterY; //self.imageView.frame.size.height/2;
self.imageView.center = center;

//Center text
CGRect newFrame = [self titleLabel].frame;
newFrame.origin.x = 0;
newFrame.origin.y =_titleOriginY; //self.imageView.frame.size.height + 5;
newFrame.size.width = self.frame.size.width;

self.titleLabel.frame = newFrame;
self.titleLabel.textAlignment =NSTextAlignmentCenter;

}

@end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容