工作常用样式UIButton封装

文章底部有源码Demo

  • 发布内容样式按钮,如下图所示:


    工作常用样式UIButton封装_第1张图片
    发布内容样式.png

    代码示例:
    注意:此方法设置CGRectMake尺寸的时候高比宽要多出至少20,否则无法正常显示出文字,如以下代码所示

CGRect frame = CGRectMake(WYScreenW * 0.5 - 60 * 0.5, 100, 60, 80);
self.testBtn = [[WYButton alloc]initWithFrame:frame bigImageName:@"publish-video" buttonTitle:@"段子" FontSize:15];
self.testBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15.0];
[self.view addSubview:self.testBtn];
  • 功能界面展示按钮样式,如下图所示:


    工作常用样式UIButton封装_第2张图片
    功能界面展示样式.png

    代码示例:
    注意:此方法设置CGRectMake尺寸,宽和高相等即可,如以下代码所示

CGRect frame = CGRectMake(WYScreenW * 0.5 - 60 * 0.5, 200, 60, 60);
self.testBtn = [[WYButton alloc]initWithFrame:frame mediumImageName:@"publish-video" buttonTitle:@"我的爱好" FontSize:13];
self.testBtn.titleLabel.font = [UIFont boldSystemFontOfSize:13.0];
[self.view addSubview:self.testBtn];
  • 图片和文字混合按钮,如下图所示:


    工作常用样式UIButton封装_第3张图片
    演示Demo.gif

    代码示例:
    共有四个方向可设置,wy_imageLeftTitleRight枚举值选择,Demo中有使用参考

CGRect frame1 = CGRectMake(maginStart, 300, 60, 60);
WYButton *testBtn1 = [[WYButton alloc]initWithFrame:frame1 buttonTitle:@"发布" backgroundImage:@"releaseBtn" FontSize:13 ImageName:@"release" AlignMode:wy_imageLeftTitleRight];
[self.view addSubview:testBtn1];

Demo下载:WYButton下载

勤学如早春之苗,不见其增,日有所涨。
辍学如磨刀之石,不见其减,日有所损。

你可能感兴趣的:(工作常用样式UIButton封装)