Skip to content

Instantly share code, notes, and snippets.

View mnaruse's full-sized avatar
🏠
Working from home

miharu mnaruse

🏠
Working from home
View GitHub Profile
@mnaruse
mnaruse / locationManagerDidChangeAuthorization.swift
Created July 8, 2020 17:58
WWDC20: What's new in location.
// 古いdidChangeAuthorizationStatusコールバックを廃止し、
// 新しいlocationManagerDidChangeAuthorizationコールバックに置き換えています。
// この新しいメソッドは、authorizationStatus または accuracyAuthorization プロパティの値が変更されるたびに呼び出されます。
// iOS13
optional func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
// iOS14
optional func locationManagerDidChangeAuthorization(_ manager: CLLocationManager)
@mnaruse
mnaruse / accuracyAuthorization.swift
Created July 8, 2020 17:53
WWDC20: What's new in location.
// iOS14
// アプリがどれだけ正確にユーザーの位置を知ることができるかを示す新しいインスタンスプロパティ
let accuracyAuthorization: CLAccuracyAuthorization { get }
enum CLAccuracyAuthorization {
case fullAccuracy // iOS14以前からのデフォルト
case reduceAccuracy // New
}
@mnaruse
mnaruse / authorizationStatus.swift
Created July 8, 2020 17:47
WWDC20: What's new in location.
// iOS 13
class func authorizationStatus() -> CLAuthorizationStatus
// iOS14
let authorizationStatus: CLAuthorizationStatus { get }
@mnaruse
mnaruse / GradientLayer
Created July 7, 2020 18:24
A gradientLayer sample.
let gradientLayer = CAGradientLayer()
gradientLayer.frame = rect
gradientLayer.colors = [
UIColor.orange.cgColor,
UIColor.red.cgColor,
UIColor.purple.cgColor,
UIColor.blue.cgColor
]
gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.0)
gradientLayer.endPoint = CGPoint(x: 1.0, y: 1.0)
if which "${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" >/dev/null; then
"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" "$SRCROOT"
else
echo "SwiftFormat does not exist, download from https://github.com/nicklockwood/SwiftFormat"
fi
if which "${PODS_ROOT}/SwiftLint/swiftlint" >/dev/null; then
git diff --name-only | grep .swift | while read filename; do
"${PODS_ROOT}/SwiftLint/swiftlint" --path "$filename"
done
else
echo "SwiftLint does not exist, download from https://github.com/realm/SwiftLint"
fi
@mnaruse
mnaruse / Podfile-favorite
Created June 14, 2020 10:53
My favorit "Podfile".
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
abstract_target 'All' do
# Pods for All
pod 'SwiftFormat/CLI'
@mnaruse
mnaruse / .swiftformat
Created June 14, 2020 10:48
My favorite ".swiftformat" file.
# file options
--exclude Pods,Generated
# format options
--allman false
--binarygrouping 4,8
--commas inline
--comments indent
@mnaruse
mnaruse / .swiftformat
Created June 14, 2020 10:48
My favorite ".swiftformat" file.
# file options
--exclude Pods,Generated
# format options
--allman false
--binarygrouping 4,8
--commas inline
--comments indent
@mnaruse
mnaruse / .swiftlint.yml
Created June 14, 2020 10:45
My favorite ".swiftlint.yml" file.
included:
- Practice_SwiftStyle
# - Source
# - Tests
# 対象外のファイル・フォルダ
excluded:
# - Tests/SwiftLintFrameworkTests/Resources
- Pods/
- Generated