美文网首页
OC_ 好多叠在一起的 button 封装

OC_ 好多叠在一起的 button 封装

作者: LiYaoPeng | 来源:发表于2018-10-08 20:55 被阅读0次
UIViewHandler.gif

很简单但是总是遇到这个控件,每次都写感觉好烦,就封装了一个0.0

代码点这里
用到的一些其他代码
masonry
view的链式设置
label属性的链式设置
NSMutableAttributedString属性链式处理
NSString属性链式处理
button属性的链式设置

调用

懒加载

- (FoldButtonsView *) foldButtonsView {
    if (!_foldButtonsView) {
        _foldButtonsView = [FoldButtonsView new];
        FoldButtonsViewConfig *config = [FoldButtonsViewConfig new];
        
        config
        .setEdge(UIEdgeInsetsMake(10, 10, 10, 10))// 编剧
        .setDeriction(FoldButtonsViewDerictionLeft_Right)//左对齐
        .setAligment(FoldButtonsViewAligment_left)
        .setFoldDistance(20)//button重叠距离
        .setMaxButtonCount(5);
        
        //设置view的基本属性
        _foldButtonsView
        .setConfig(config)
        .setUpBorderColor(UIColor.redColor)
        .setUpBorderWidth(1)
        .setUpBackgroundColor(UIColor.whiteColor);
        
        // button创建的时候会调用,只有在改变maxButtonCount 的时候,才会重新创建button
        [_foldButtonsView setupButtonWhenCreatingFunc:^(NSInteger index, UIButton *button) {
        }];
    }
    return _foldButtonsView;
}

修改foldButtonsView内部的button

  [self.foldButtonsView reloadDataToIndex:8 block:^(NSInteger index, UIButton *button) {
            [button setUpStyle:UIControlStateNormal style:^(UIButton *button) {
                button
                .setUpBackgroundImage([UIImage imageNamed:@"".addInt(index)])
                .setUpBackgroundColor(UIColor.whiteColor)
                .setUpTitleColor(UIColor.redColor)
                .setUpBorderWidth(2)
                .setUpBorderColor(UIColor.redColor)
                .setUpFont([UIFont systemFontOfSize:24])
                .setUpMasksToBounds(true)
                .setUpCornerRadius(button.frame.size.width/2.0);
            }];
        }];
左对齐,左边第一个按钮在展示完全
config
        .setDeriction(FoldButtonsViewDerictionLeft_Right)//左对齐
        .setAligment(FoldButtonsViewAligment_left)
左对齐,右边第一个按钮在展示完全
 config
        .setDeriction(FoldButtonsViewDerictionRight_Left)//左对齐
        .setAligment(FoldButtonsViewAligment_left)
右对齐,左边第一个按钮在展示完全
config
        .setDeriction(FoldButtonsViewDerictionLeft_Right)
         .setAligment(FoldButtonsViewAligment_right)
右对齐,右边第一个按钮在展示完全
config
        .setDeriction(FoldButtonsViewDerictionRight_Left)
        .setAligment(FoldButtonsViewAligment_right)

代码点这里

相关文章

  • OC_ 好多叠在一起的 button 封装

    很简单但是总是遇到这个控件,每次都写感觉好烦,就封装了一个0.0 代码点这里用到的一些其他代码masonryvie...

  • iOS排序方法集合

    OC_选择排序 OC_冒泡排序 参考原文:排序算法

  • 封装button组件

    参考elementui,给button一个type="paramy"属性,一个round,用来控制颜色和圆角com...

  • react naive封装原生UI(android篇)

    本文对于UI组件的封装,主要从两部分介绍: 基本视图封装 事件处理 demo中是封装原生Button组件,记录使用...

  • vue2.6.0以上版本 jsx/tsx slot插槽

    组件采用tsx 语法,需要使用到插槽。简单封装一个button组件,举个例子。 Button/index.tsx ...

  • ios控件UIButton的封装

    通过block对button的点击事件封装 具体的实现过程 typedefvoid(^tapActionBlock...

  • React Native Button封装

    react native 开发时,自带的button组件不能满足我们的开发需求。不支持背景图等设置。所以封装了一个...

  • iOS Category库工具简单封装介绍

    简单介绍这个库的大致内容:Category各种工具集合,Button图文混排、点击事件封装、扩大点击域,手势封装、...

  • React Native之组件

    View 视图 实例1 Button 按钮 例1 属性 TouchableHighlight 用来封装可触摸视图 ...

  • block不仅仅用来传值

    你的反馈是我更新的动力.本文适合初学者阅读封装一个有button的view ,在VC中使用.实现点击button的...

网友评论

      本文标题:OC_ 好多叠在一起的 button 封装

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