# EasyCoding **Repository Path**: fanxx/EasyCoding ## Basic Information - **Project Name**: EasyCoding - **Description**: No description available - **Primary Language**: Swift - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-19 - **Last Updated**: 2022-08-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # EasyCoding ## Example To run the example project, clone the repo, and run `pod install` from the Example directory first. 部分示例: ### 1. 视图创建语法糖 ```swift let view = UIView() let label2 = UILabel.easy(.color(.red), .font(size: 15), .text("第二个Label")) view.easy.build { //添加UILabel()到UIView()上,顶部对齐,两边间隔20, 蓝色苹方粗体18号 UILabel.easy.config(.color(.blue), .font(UIFont.easy.pingfang(bold: 18), .text("第一个Label"))) .layout(.top, .margin(20)) //添加label2到上面的UIView()上,顶部间隔上一个UILabel()的底部15,跟父控件x轴中间对齐,底部贴着父控件间隔30,红色系统15号字体 label2.easy.layout(.bottomTop(15)) .layout(for: .parent, .centerX, .bottom(30)) } ``` .easy.add: 将参数视图添加到当前视图,layout参数的针对当前视图相对于参数视图布局,内部还是使用了snapKit 详细使用参考1.4.3.ViewBuilder目录及1.4.2.ViewStyle目录下的类 ### 2.AttributedString语法糖 ```swift NSAttributedString.easy("我是一段富文本,文本很\("富", .color(.red)),我很\("穷", .color(.green), .boldFont(size: 30))", .color(rgb: 0x333333), .font(size: 15)) ``` ```swift NSAttributedString.easy.build(.color(rgb: 0x333333), .font(size: 15)) { "我是一段富文本,文本很" "富".easy.attr(.color(.red)) "我很" "穷".easy.attr(.color(.green), .boldFont(size: 30)) } ``` 创建一个NSAttributedString,全局颜色深灰,15号系统字体,里面的"富"字红字,"穷"字绿字,加粗30号系统字体 上面两种语法都可以,复杂的建议用下面那种,阅读性比较强,简单的用上面的比较简洁 暂时写这么点,其他还有很多可以参考demo和源码,源码都按目录分好了,很多没有写demo,懒得写了 ## Requirements Swift 5.4 ## Installation EasyCoding is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your Podfile: ```ruby pod 'EasyCoding' ``` ## Author fanxiaoxin_1987@126.com, fanxiaoxin_1987@126.com ## License EasyCoding is available under the MIT license. See the LICENSE file for more info.