This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let collectionView = ZoomableCollectionView(frame:self.view.frame) | |
self.view.addSubview(collectionView) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVFoundation | |
import ImageIO | |
import MobileCoreServices | |
import WebKit | |
class GIFWebViewController: UIViewController { | |
var imageArray:[CGImage]! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class MyShapeLayer: CALayer { | |
func drawRect(lineWidth:CGFloat){ | |
let rect = CAShapeLayer() | |
rect.strokeColor = UIColor.black.cgColor | |
rect.fillColor = UIColor.clear.cgColor | |
rect.lineWidth = lineWidth | |
rect.path = UIBezierPath(rect:CGRect(x:0,y:0,width:self.frame.width,height:self.frame.height)).cgPath | |
self.addSublayer(rect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class CalendarCell: UICollectionViewCell { | |
public var textLabel:UILabel! | |
required init(coder aDecoder:NSCoder){ | |
super.init(coder: aDecoder)! | |
} | |
override init(frame:CGRect){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array { | |
func findIndex(includeElement: (Element) -> Bool) -> [Int] { | |
var indexArray:[Int] = [] | |
for (index, element) in enumerated() { | |
if includeElement(element) { | |
indexArray.append(index) | |
} | |
} | |
return indexArray | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Dictionary { | |
//only [String:Int] | |
func maxKey() -> [String]?{ | |
guard let values = Array(self.values) as? [Int] else { return nil } | |
guard let _ = Array(self.keys) as? [String] else { return nil } | |
//valueの最大値を取り出す | |
guard let max = values.max() else { return nil } | |
var maxKeys:[String] = [] | |
//辞書の中身をひとつずつ見ていく |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func resize(size:CGSize) -> UIImage?{ | |
// リサイズ処理 | |
let origWidth = self.size.width | |
let origHeight = self.size.height | |
var resizeWidth:CGFloat = 0 | |
var resizeHeight:CGFloat = 0 | |
if (origWidth < origHeight) { | |
resizeWidth = size.width |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class AlertManager { | |
let id = "alert" | |
var text = "通知が来ているはずだよ" | |
//現在の時間から | |
func after(day:Int,hour:Int,minute:Int,seconds:Int) -> UILocalNotification{ | |
//ローカル通知 |