LoginSignup
4
4

More than 5 years have passed since last update.

Swift覚書02 頻度低

Posted at

自分用の覚え書きです。
Swift1.x混ざってるかも。

背景を敷き詰める

let collectionViewBg:UIImage = UIImage(named: "bg.png")!
self.view.backgroundColor = UIColor(patternImage: collectionViewBg)

アニメーション基本構文

UIView.animateWithDuration(
    0.4,
    delay: 0.4,
    options: UIViewAnimationOptions.CurveEaseOut,
    animations: {
        //
    },
    completion:{
        (value: Bool) in

    }
)

UIViewのhitTest

 override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {

        let rv:UIView? = super.hitTest(point , withEvent: event)
        return rv == self ? nil : rv

    }

NSDate

NSDateFormatterマジ便利。 曜日をとる場合はカレンダークラスで。

NSDateから文字列

let dateFormatter = NSDateFormatter() // フォーマットの取得
dateFormatter.locale = NSLocale(localeIdentifier: "ja_JP")  // JPロケール
dateFormatter.dateFormat = "yyyy/MM/dd HH:mm:ss" // フォーマットの指定
print(dateFormatter.stringFromDate( NSDate() ) )

文字列からNSDate

var date_string: String = "2014-12-01 10:00:00"
var date_formatter: NSDateFormatter = NSDateFormatter()
date_formatter.locale     = NSLocale(localeIdentifier: "ja")
date_formatter.dateFormat = "yyyy/MM/dd HH:mm:ss"
date_formatter.dateFromString( date_string )
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4