自定义一个图片在上,文字在下的按钮
来源:互联网 发布:sql注入病毒的原理 编辑:程序博客网 时间:2024/04/29 03:58
//// MenuItemButton.h#import <UIKit/UIKit.h>@interface MenuItemButton : UIButton@end
//// MenuItemButton.m#import "MenuItemButton.h"#define kImageRatio 0.8@implementation MenuItemButton- (void)awakeFromNib{ [self setup];}- (instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self setup]; } return self;}- (void)setup{ self.imageView.contentMode = UIViewContentModeCenter; self.titleLabel.textAlignment = NSTextAlignmentCenter;}// 如果通过代码设置子控件位置,都是在layoutSubviews里面- (void)layoutSubviews{ [super layoutSubviews]; // imageView CGFloat imageX = 0; CGFloat imageY = 0; CGFloat imageW = self.bounds.size.width; CGFloat imageH = self.bounds.size.height * kImageRatio; self.imageView.frame = CGRectMake(imageX, imageY, imageW, imageH); // titleLabel CGFloat labelY = imageH; CGFloat labelH = self.bounds.size.height - labelY; self.titleLabel.frame = CGRectMake(imageX, labelY, imageW, labelH);}@end
0 0
- 自定义一个图片在上,文字在下的按钮
- 按钮图片在上文字在下
- 自定义RadioButton 文字在下,图片在上
- 自定义RadioButton 文字在下,图片在上
- 自定义RadioButton 文字在下,图片在上 .
- IOS 初学 runtime 自定义Button实现按钮图片在上文字在下
- iOS按钮设置图片在上文字在下
- iOS UIButton按钮图片在上文字在下
- iOS按钮设置图片在上文字在下
- swift 自定义UIButton 图片在上 文字在下
- UIButton设置图片在上 文字在下的方法
- 自定义UIButton,文字图片位置设置 例:图片在上文字在下
- 实用知识:UIButton 图片在上文字在下
- Swift里自定义一个文字在左、图片在右的,标题按钮
- 自定义图片在上边,文字在下边的按钮
- 自定义一个文字居左图片居右的按钮
- Android笔记--一个图片+文字的自定义按钮
- iOS实战演练之——封装图片在上文字在下的button以及相关问题
- PHP 运行方式(PHP SAPI介绍)
- 屏蔽Adobe连接验证服务器
- 安卓数据库编程总结(1)
- Host 'heChengjian' is not allowed to connect to this MySQL server
- webservice 入门笔记三通过payload发送消息
- 自定义一个图片在上,文字在下的按钮
- 《机器学习实战》小结
- 数据结构 - 2顺序表及链表基本运算实现
- Source Insight阅读Matlab源码设置流程(其他语言也通用)
- 吴恩达机器学习笔记_第二周
- getaddrinfo函数
- 自定义View(一)
- android studio出现非法字符的解决办法
- 各种排序算法时间复杂度和空间复杂度表