Latest 1.0.1
Homepage https://github.com/PSSDeveloper/PSTagAlignView
License MIT
Platforms ios 8.0, requires ARC
Authors
  • 一个自定义标签显示视图,可选择左对齐或者右对齐。
  • 该自定视图会根据填充的数据以及视图的宽度自动给出完成布局之后的整体高度。

使用方式

//现已支持cocoaPods引入
pod 'PSTagAlignView', '~> 1.0'
/**要显示的数据源*/
NSArray *dataArray = @[@"金城郡", @"安定郡", @"北地郡",@"陈国", @"武威郡", @"张掖郡", @"梁国", @"酒泉郡", @"敦煌郡", @"张掖属国",@"中山国", @"沛国", @"居延属国",@"陇西郡",@"汉阳郡", @"鲁国",@"武都郡"];
/** 
    按照此格式传入配置参数 
    textFont:字体
    textColor:字体颜色
    borderColor:边框颜色
    borderRadius:圆角大小
*/
NSDictionary *configDic = @{@"textFont": [UIFont systemFontOfSize:14],
                            @"textColor": [UIColor orangeColor],
                            @"borderColor": [UIColor orangeColor],
                            @"borderRadius": [NSNumber numberWithFloat:10.f]
                            };
/** 
    itemMarign为item的间距
    PSTagAlignView默认左对齐显示

*/
PSTagAlignView *tagAlignView = [PSTagAlignView tagAlignViewWithContents:dataArray itemMarign:5.0 configDict:configDic];
[self.view addSubview:tagAlignView];

__weak typeof(self) weakSelf = self;
/** 根据数据源填充之后返回整体高度,便于开发者进行更新约束 */
tagAlignView.completionBlock = ^(CGFloat height) {
    weakSelf.heightConstarint.constant = height;
};
//填充数据方法    
[tagAlignView reloadData];
//更改数据的对其显示方式
//右对齐
self.tagAlignView.alignStyle = PSTagAlignStyleRight;
[self.tagAlignView reloadData];

演示效果

图例

Latest podspec

{
    "name": "PSTagAlignView",
    "version": "1.0.1",
    "summary": "u4e00u4e2au81eau5b9au4e49u6807u7b7eu663eu793au89c6u56feuff0cu53efu9009u62e9u5de6u5bf9u9f50u6216u8005u53f3u5bf9u9f50u3002",
    "description": "u4e00u4e2au81eau5b9au4e49u6807u7b7eu663eu793au89c6u56feuff0cu53efu9009u62e9u5de6u5bf9u9f50u6216u8005u53f3u5bf9u9f50,nu8be5u81eau5b9au89c6u56feu4f1au6839u636eu586bu5145u7684u6570u636eu4ee5u53cau89c6u56feu7684u5bbdu5ea6u81eau52a8u7ed9u51fau5b8cu6210u5e03u5c40u4e4bu540eu7684u6574u4f53u9ad8u5ea6u3002",
    "homepage": "https://github.com/PSSDeveloper/PSTagAlignView",
    "license": "MIT",
    "authors": {
        "PSSDeveloper": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/PSSDeveloper/PSTagAlignView.git",
        "tag": "1.0.1"
    },
    "source_files": "PSTagAlignView/PSTagAlignView/PStagAlinView/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This