目前分類:iOS (229)
- Mar 16 Fri 2018 12:07
[iOS] 解決Gradient layer frame 更新很慢
- Mar 13 Tue 2018 16:01
[iOS] 清WebView cookie
清 UIWebView, WKWebView, SafariViewController cookie 相關的解法的好文章
- Feb 27 Tue 2018 11:01
[Swift] Constraint isActive = nil
- Feb 07 Wed 2018 13:36
[iOS Carthage] 切換Swift build version
- Feb 07 Wed 2018 13:33
[Xcode 9.2] 加速Swift build time
defaults write com.apple.dt.Xcode BuildSystemScheduleInherentlyParallelCommandsExclusively -bool NO
- Feb 06 Tue 2018 15:25
[iOS] viewForHeaderInSection會不見
- Jan 28 Sun 2018 16:54
[Xcode] 自製JSON to Swift struct model (Xcode extension)
- Jan 08 Mon 2018 12:32
[iOS] 解決ImageView沒有圓角及陰影的問題
- Dec 13 Wed 2017 10:17
[iOS] 解決Homebrew carthage 不能裝
- Nov 20 Mon 2017 15:20
[Swift] 讓Tabbar與NavigationItem 顯示不同
- Nov 13 Mon 2017 14:25
[iOS] CocoaPods 更新多個repo
- Aug 13 Sun 2017 19:07
[Swift] ObservableCell
- Mar 17 Fri 2017 09:58
[Swift] 文字轉語音
import UIKit import AVFoundation extension Date { func toString(format: String) -> String { let dateFormat = DateFormatter() dateFormat.dateFormat = format return dateFormat.string(from: self) } } class ViewController: UIViewController { @IBOutlet weak var textView: UITextView! let synth = AVSpeechSynthesizer() var timer = Timer() @IBAction func startHandler(_ sender: UIButton) { timer.invalidate() timer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { [weak self] (timer) in guard let weakSelf = self else { return } let text = "現在時刻:" + Date().toString(format: "HH:mm") weakSelf.textView.text = text let myUtterance = AVSpeechUtterance(string: text) myUtterance.voice = AVSpeechSynthesisVoice(language: "zh-TW") myUtterance.rate = 0.5 weakSelf.synth.speak(myUtterance) } timer.fire() } @IBAction func endHandler(_ sender: UIButton) { timer.invalidate() synth.stopSpeaking(at: .word) } }
- Mar 10 Fri 2017 05:40
[SourceTree] 還原以前某個commit (Reverse commit)) 用法
通常在Run專案的時候,可能會有些修改(例如: 還原以前砍掉的某個功能...),如果以前的commit的東西,有用最小單位來commit的話.. ,這樣可以很輕鬆的使用SourceTree的Reverse commit,來還原某筆的commit (他會建立一個完全相反的commit,新增變刪除、刪除變新增)。
- Mar 05 Sun 2017 01:35
[Swift] async await
主要受到下面兩個很神的Github repository的影響,嘗試自己做一個類似C# async await功能
- Feb 28 Tue 2017 03:59
[Swift] try PromiseKit
Swift的Promise,可以把非同步的Code用then then then串接下去(解決Callback hell),試用了一下還蠻讚的,跟javascript的一樣好用@@
- Feb 27 Mon 2017 13:19
[iOS 10] [watchOS 3] 手錶手電筒App送審中
手電筒App送審中。
- Feb 20 Mon 2017 09:29
SourceTree commit的註解視窗不見
defaults delete com.torusknot.SourceTreeNotMAS "NSSplitView Subview Frames repowindow_LogViewDescSplitter"
- Feb 12 Sun 2017 19:06
[Swift] 只在Debug Mode 輸出 Print
func print(_ items: Any...) 為主要的Function,需放置全域的位置 (外層不能有東西)
func print(_ items: Any...) { #if DEBUG for item in items { print(item, separator: " ", terminator: "\n") } #endif } public struct Utilities { public static func openSafari(_ urlString: String) { guard let urlEncoded = urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) else { print("無法URL Encode, \(#function): urlString") return } guard let url = URL(string: urlEncoded) else { print("無法轉換成URL, \(#function): urlString") return } UIApplication.shared.open(url) } }
接下來就能在其它地方照常使用print輸出,而Release Mode,print內的#if DEBUG包住的地方將不會被編譯而變成Empty Function,這時Swift Compiler將會把function call整個拿掉,似乎是完美的作法。
- Jan 15 Sun 2017 03:34
[Swift][Extension] Type to String
將Type轉換成字串的extension
extension String { init<T>(type: T.Type) { self = "\(type.self)" } init<T>(type: T) { self = "\(type(of: type))" } }