美文网首页
iOS Button实现图片与文字混排

iOS Button实现图片与文字混排

作者: 奔跑的兔崽子 | 来源:发表于2017-12-26 13:40 被阅读0次

本文用来记录自己开发过程中遇到的问题,以及好的第三方等等。

文字在左,图片在右;文字在右,图片在左;文字在上,图片在下;文字在下,图片在上;

使用自定义view,image加label,然后view上面加手势实现,按钮的点击事件封装在block中。

github链接  github链接 :https://github.com/dsc7219356/customButton

实现代码如下:

CustomButton *button1 = [[CustomButton alloc]initWithFrame:(CGRect){(CGRectGetWidth(self.view.frame)-100)/2,80,100,100}

type:CustomButtonTopImageType

imageSize:CGSizeMake(50, 50) midmargin:10];

button1.isShowSelectBackgroudColor = YES;

button1.imageView.image = [UIImage imageNamed:@"image"];

button1.backgroundColor = [UIColor whiteColor];

button1.titleLabel.text = @"朋友圈";

[self.view addSubview:button1];

[button1 touchAction:^(CustomButton * _Nonnull button) {

NSLog(@"上图标,下文字");

}];

相关文章

网友评论

      本文标题:iOS Button实现图片与文字混排

      本文链接:https://www.haomeiwen.com/subject/bjmdgxtx.html