Blame view
App/camera/board/Board.swift
2.58 KB
|
1341bf603
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import Foundation
import UIKit
import GeneralUtils
@IBDesignable class Board: UIView {
@IBOutlet weak var vRoot: UIView!
@IBOutlet weak var tvDate: UILabel!
@IBOutlet weak var tvNote: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
xibSetup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
xibSetup()
}
func xibSetup() {
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: "Board", bundle: bundle)
if let view = nib.instantiate(withOwner: self, options: nil)[0] as? UIView {
view.frame = bounds
view.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
addSubview(view)
}
}
func initData() {
let date = Date()
setDate(date: date)
}
private func setDate(date: Date) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMM d, yyyy"
dateFormatter.locale = Locale(identifier: "ja_JP")
tvDate.text = dateFormatter.string(from: date)
}
@IBAction func noteClick(_ sender: Any) {
let dialog = DialogUtils.builderDialog(showCloseButton: false, showTitle: false)
let edt = dialog.addTextField()
dialog.addButton(LocalizedString("OK"), action: {
self.tvNote.text = " " + (edt.text ?? "")
})
dialog.showTitle("", subTitle: "備考", style: .edit)
edt.becomeFirstResponder()
}
@IBAction func dateClick(_ sender: Any) {
DatePickerDialog().show("撮影日", datePickerMode: .date, callback: { date in
if let date = date {
self.setDate(date: date)
//TODO
}
})
}
func scale() {
delayExcute(1, block: {
print("Scale")
UIView.animate(withDuration: 5, animations: {
self.vRoot.transform = CGAffineTransform.identity.scaledBy(x: 0.3, y: 0.3)
self.vRoot.frame.origin.x = 0
self.vRoot.frame.origin.y = 0
})
})
}
func delayExcute(_ delay: TimeInterval, queueParam: DispatchQueue? = nil, block: @escaping () -> ()) {
var queue: DispatchQueue!
if queueParam == nil {
queue = DispatchQueue.main
} else {
queue = queueParam
}
let time = DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
queue.asyncAfter(deadline: time, execute: block)
}
}
|