roundrect

所属分类:内容生成
开发工具:Swift
文件大小:3642KB
下载次数:0
上传日期:2022-08-02 19:24:39
上 传 者sh-1993
说明:  以编程方式生成图像资产和设置UIButton样式的便利性
(Conveniences for programmatically generating image assets and styling UIButton)

文件列表:
.swiftpm (0, 2021-11-04)
.swiftpm\xcode (0, 2021-11-04)
.swiftpm\xcode\package.xcworkspace (0, 2021-11-04)
.swiftpm\xcode\package.xcworkspace\contents.xcworkspacedata (135, 2021-11-04)
LICENSE (11932, 2021-11-04)
Package.swift (772, 2021-11-04)
Roundrect.h (215, 2021-11-04)
Roundrect.xcodeproj (0, 2021-11-04)
Roundrect.xcodeproj\RoundrectTests_Info.plist (723, 2021-11-04)
Roundrect.xcodeproj\Roundrect_Info.plist (743, 2021-11-04)
Roundrect.xcodeproj\project.pbxproj (23559, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace (0, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace\contents.xcworkspacedata (135, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace\xcshareddata (0, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (238, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (269, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace\xcshareddata\swiftpm (0, 2021-11-04)
Roundrect.xcodeproj\project.xcworkspace\xcshareddata\swiftpm\Package.resolved (348, 2021-11-04)
Roundrect.xcodeproj\xcshareddata (0, 2021-11-04)
Roundrect.xcodeproj\xcshareddata\xcschemes (0, 2021-11-04)
Roundrect.xcodeproj\xcshareddata\xcschemes\Roundrect.xcscheme (2457, 2021-11-04)
Sources (0, 2021-11-04)
Sources\Roundrect (0, 2021-11-04)
Sources\Roundrect\ButtonStyle.swift (6606, 2021-11-04)
Sources\Roundrect\ButtonTheme.swift (733, 2021-11-04)
Sources\Roundrect\ImageGeneration.swift (10919, 2021-11-04)
Sources\Roundrect\Roundrect.swift (52, 2021-11-04)
Sources\Roundrect\Util.swift (3739, 2021-11-04)
Tests (0, 2021-11-04)
Tests\RoundrectTests (0, 2021-11-04)
Tests\RoundrectTests\AdaptiveColorTests.swift (1601, 2021-11-04)
Tests\RoundrectTests\Assets.xcassets (0, 2021-11-04)
Tests\RoundrectTests\Assets.xcassets\Contents.json (63, 2021-11-04)
... ...

# roundrect Conveniences for programmatically generating image assets and styling UIButton. ## Creating Images The conveniences in `ImageGeneration.swift` allow images to be generated from a view, or given various style properties like fill, stroke, corner radius, etc. For example, to create a 3px/3px image with a 1px blue stroke and a single red fill: ```swift let image = UIImage( fill: .red, stroke: ( color: .blue, width: 1 ) ) ``` This image can be made resizable and applied to a `UIButton`, but since there is a lot of busywork associated with handling all the different states a button can have, the conveniences in `ButtonStyle` can be used instead. A combination of a button `Style` (eg. filled vs bordered) and `Theme` (eg. light or dark) can be provided when creating or modifying an existing `UIButton`: ```swift let button = UIButton( style: .filled( cornerRadius: 8 ) ) ``` This will yield a button with a tintable fill and a corner radius of 8. API exists for an explicit `theme` to be provided, but it's marked as obsolete as of iOS13 in favour of light/dark mode provided by `UIInterfaceStyle`. ## Contributing Snapshot tests are recorded with the **iOS 14.4 iPhone 12** simulator using the [Swift Snapshot Testing](https://github.com/pointfreeco/swift-snapshot-testing) library. ## Examples
近期下载者

相关文件


收藏者