Skip to content

Instantly share code, notes, and snippets.

View uruly's full-sized avatar
☂️

Reo uruly

☂️
View GitHub Profile
@uruly
uruly / ViewController.swift
Last active April 13, 2018 06:35
Zoomable CollectionView
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let collectionView = ZoomableCollectionView(frame:self.view.frame)
self.view.addSubview(collectionView)
}
import UIKit
class SwipeNavigationViewController: UINavigationController {
var pageScrollView:UIScrollView!
var viewControllerArray:[UIViewController] = []
var pageController:UIPageViewController!
//固定して表示するもの
var closeBtn:UIButton!
import UIKit
import AVFoundation
import ImageIO
import MobileCoreServices
import WebKit
class GIFWebViewController: UIViewController {
var imageArray:[CGImage]!
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)
import UIKit
class CalendarCell: UICollectionViewCell {
public var textLabel:UILabel!
required init(coder aDecoder:NSCoder){
super.init(coder: aDecoder)!
}
override init(frame:CGRect){
extension Array {
func findIndex(includeElement: (Element) -> Bool) -> [Int] {
var indexArray:[Int] = []
for (index, element) in enumerated() {
if includeElement(element) {
indexArray.append(index)
}
}
return indexArray
}
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] = []
//辞書の中身をひとつずつ見ていく
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
@uruly
uruly / AlertManager.swift
Last active April 12, 2018 01:00
LocalNotification
import UIKit
class AlertManager {
let id = "alert"
var text = "通知が来ているはずだよ"
//現在の時間から
func after(day:Int,hour:Int,minute:Int,seconds:Int) -> UILocalNotification{
//ローカル通知
import UIKit
@objc protocol UpDownCountButtonDelegate {
func touchDown(sender:UIButton)
func touchCancel(sender:UIButton)
}
class UpDownCountButton: UIButton {