Skip to content

Lionyy/dev_tips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

扩展按钮点击范围

  • 继承UIBUTTON, 重写方法- (CGRect)backgroundRectForBounds:(CGRect)contentRect决定背景图大小,实际按钮大小可以扩大。

OC示例代码 

@interface LYExpendButton : UIButton
@end

@implementation LYExpendButton

- (CGRect)backgroundRectForBounds:(CGRect)contentRect {
     CGFloat x = ceilf(contentRect.size.width - 54)/2;
     CGFloat y = ceilf(contentRect.size.height - 22)/2;
     CGFloat width = 54;
     CGFloat height = 22;
     return CGRectMake(x, y, width, height);
}
@end

About

总结开发中遇到一些小技巧!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published