Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomortec/simplemagnifyingview
SimpleMagnifyingView can be used as a magnifier as the one iOS providing 🔍. SwiftUI supported!
https://github.com/tomortec/simplemagnifyingview
ios magnifier swift swiftui tomortec ui
Last synced: 2 months ago
JSON representation
SimpleMagnifyingView can be used as a magnifier as the one iOS providing 🔍. SwiftUI supported!
- Host: GitHub
- URL: https://github.com/tomortec/simplemagnifyingview
- Owner: Tomortec
- License: mit
- Created: 2022-04-28T05:29:29.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-05-04T15:26:56.000Z (over 2 years ago)
- Last Synced: 2024-10-31T16:33:05.978Z (3 months ago)
- Topics: ios, magnifier, swift, swiftui, tomortec, ui
- Language: Swift
- Homepage:
- Size: 1.77 MB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-zh.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleMagnifyingView
`SimpleMagnifyingView` 是用 SwiftUI 写的放大镜 🔍
## 原理
## 小示例
``` Swift
MagnifierView(isMagnifying: $isMagnifying, scale: .constant(1.8)) {
Text("Hello world")
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.cyan)
}
.outlineColor(.white)
.closeButtonColor(.white)
```克隆本仓库,在 `Example` 文件夹执行 `pod install` 后在 `Xcode` 运行示例项目来查看 demo
## 接口
### 初始化
``` swift
init(
isMagnifying: Binding, // 控制可见性
scale: Binding = .constant(2.0),
glassShape: AnyShape = AnyShape(RoundedRectangle(cornerRadius: 12.0)),
@ViewBuilder _ content: () -> Content
)
```### 有关放大镜的方法
``` swift
// 调整放大镜的尺寸
func magnifyingGlassSize(_ size: CGSize)// 设置放大镜的形状
func magnifyingGlassShape(_ shape: AnyShape)// 设置把柄的宽度比例(相对于放大镜的宽度)
func handleWidthRatio(_ ratio: CGFloat)// 设置把柄的高度
func handleHeight(_ height: CGFloat)// 设置放大镜的边框颜色
func outlineColor(_ color: Color)// 设置放大镜的边框宽度
func outlineWidth(_ width: CGFloat)// 是否允许在放大镜内交互
func enableHitInMagnifyingGlass(_ enabled: Bool)
```### 有关 mask 的方法
``` swift
// 设置 mask 的背景颜色
func maskBackgroundColor(_ color: Color)// 设置关闭按钮的尺寸
func closeButtonSize(_ size: CGSize)// 设置关闭按钮的颜色
func closeButtonColor(_ color: Color)// 是否显示关闭按钮
func enableCloseButton(_ enabled: Bool)
```执行 Xcode 的 `Product > Build Documentation` 并前往文档中心来查看 `SimpleMagnifyingView` 的更多接口细节
## Swift 版本
Swift >= 5.0
## 安装方法
`SimpleMagnifyingView` 已在 [CocoaPods](https://cocoapods.org)发布。添加下列命令到你的 `Podfile` 来安装 `SimpleMagnifyingView`:
```ruby
pod 'SimpleMagnifyingView'# 注意:如果您的 pod 没找到 `SimpleMagnifyingView`, 请使用下面的命令重试
# pod `SimpleMagnifyingView`, :git => 'https://github.com/Tomortec/SimpleMagnifyingView.git'
```## 作者
Tomortec, [email protected]
## License
SimpleMagnifyingView is available under the MIT license. See the LICENSE file for more info.