DragDropUI
一组具有拖放功能的iOS UI组件。还有一个由@gerchicov-bp翻译成俄语的链接。
要求
DragDropUI版本 | 最小iOS目标 | Swift版本 |
---|---|---|
1.1.0 | 11.0 | 5.x |
1.0.5 | 9.0 | 5.x |
1.0.4 | 9.0 | 4.1 |
1.0.3 | 9.0 | 4.0 |
1.0.2 | 8.0 | 3.x |
CocoaPods
CocoaPods是Cocoa项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用CocoaPods将DragDropUI集成到Xcode项目中,在Podfile中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'DragDropUI', '~> 1.1.0'
end
然后,运行以下命令
$ pod install
Carthage
Carthage是一个集中的依赖管理器,它会构建您的依赖项并为您提供二进制框架。
您可以使用以下命令使用 Homebrew 安装 Carthage:
brew update
brew install carthage
要使用 Carthage 将 DragDropUI 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它:
github "abdullahselek/DragDropUI" ~> 1.1.0
运行 carthage update 命令以构建框架,然后将构建的 DragDropUI.framework 拖到您的 Xcode 项目中。
Swift Package Manager
修改您的 Package.swift
文件,以包含以下依赖项:
.package(url: "https://github.com/abdullahselek/DragDropUI.git", from: "1.0.5")
运行 swift package resolve
DragDropUI 包含:
- DDView
- DDButton
- DDImageView
- DDLabel
- DDTableViewCell
- DDCollectionViewCell
- DDTextField
使用这些组件非常简单。您可以直接将它们添加到Storyboard或Xib文件中,并使用DD类设置其类。
如果您更愿意通过代码添加,这也是可以的。使用框架创建并添加约束就足够了!
示例用法
import UIKit
import DragDropUI
class ViewController: UIViewController {
@IBOutlet weak var draggableView: DDView!
override func viewDidLoad() {
super.viewDidLoad()
draggableView.ddDelegate = self
}
}
extension ViewController: DDViewDelegate {
func viewWasDragged(view: UIView, draggedPoint: CGPoint) {
print(NSStringFromCGPoint(draggedPoint))
}
func viewWasDropped(view: UIView, droppedPoint: CGPoint) {
print(NSStringFromCGPoint(droppedPoint))
}
}
许可协议
MIT License
Copyright (c) 2016 Abdullah Selek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.