目前分類:iOS (229)

瀏覽方式: 標題列表 簡短摘要

自己SubClass UIView,然後再對layer做Gradient

 

小賢 發表在 痞客邦 留言(0) 人氣()

清 UIWebView, WKWebView, SafariViewController cookie 相關的解法的好文章

https://github.com/OAuthSwift/OAuthSwift/wiki/Logout

小賢 發表在 痞客邦 留言(0) 人氣()

將 weak 拿掉(變成strong ) 就行了@@

 

小賢 發表在 痞客邦 留言(0) 人氣()

 

小賢 發表在 痞客邦 留言(0) 人氣()

defaults write com.apple.dt.Xcode BuildSystemScheduleInherentlyParallelCommandsExclusively -bool NO

 

小賢 發表在 痞客邦 留言(0) 人氣()

使用 UITableViewHeaderFooterView ,而非 UITableViewCell來做 Header Section 就能解決這個問題....

 

小賢 發表在 痞客邦 留言(0) 人氣()


小賢 發表在 痞客邦 留言(0) 人氣()

View (設陰影)

   View (設圓角, maskToBound, clipToBound )

小賢 發表在 痞客邦 留言(0) 人氣()

sudo chown -R $(whoami):admin /usr/local && sudo chmod -R g+rwx /usr/local

 

小賢 發表在 痞客邦 留言(0) 人氣()

在該頁的ViewController中指定成不同的Title

例如:

小賢 發表在 痞客邦 留言(0) 人氣()

bosian$ pod update 'Fabric' 'Crashlytics'

 

小賢 發表在 痞客邦 留言(0) 人氣()

 

小賢 發表在 痞客邦 留言(0) 人氣()

 

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)
    }
}

 

小賢 發表在 痞客邦 留言(0) 人氣()

    通常在Run專案的時候,可能會有些修改(例如: 還原以前砍掉的某個功能...),如果以前的commit的東西,有用最小單位來commit的話.. ,這樣可以很輕鬆的使用SourceTree的Reverse commit,來還原某筆的commit (他會建立一個完全相反的commit,新增變刪除、刪除變新增)。

小賢 發表在 痞客邦 留言(0) 人氣()

    主要受到下面兩個很神的Github repository的影響,嘗試自己做一個類似C# async await功能

https://github.com/yannickl/AwaitKit

小賢 發表在 痞客邦 留言(0) 人氣()

    Swift的Promise,可以把非同步的Code用then then then串接下去(解決Callback hell),試用了一下還蠻讚的,跟javascript的一樣好用@@

 

小賢 發表在 痞客邦 留言(0) 人氣()

手電筒App送審中。

小賢 發表在 痞客邦 留言(0) 人氣()

 

defaults delete com.torusknot.SourceTreeNotMAS "NSSplitView Subview Frames repowindow_LogViewDescSplitter"

 

小賢 發表在 痞客邦 留言(0) 人氣()

  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整個拿掉,似乎是完美的作法。

小賢 發表在 痞客邦 留言(0) 人氣()

將Type轉換成字串的extension

extension String {
    
    init<T>(type: T.Type) {
        self = "\(type.self)"
    }
    
    init<T>(type: T) {
        self = "\(type(of: type))"
    }
}

 

小賢 發表在 痞客邦 留言(0) 人氣()