Skip to content

Instantly share code, notes, and snippets.

View yusufozgul's full-sized avatar
👻
Working from anywhere

Yusuf Özgül yusufozgul

👻
Working from anywhere
View GitHub Profile
@yusufozgul
yusufozgul / gradientColor.swift
Last active May 27, 2019 08:54
Gradient Color
// Bir view oluşturalım.
let gradientView = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400))
// gradient layer oluşturuyoruz
let gradient = CAGradientLayer()
// gradient'imiz için renkleri array halinde ekliyoruz.
gradient.colors = [UIColor.red.cgColor, UIColor.blue.cgColor]
// soldan sağa gradient olması
@yusufozgul
yusufozgul / GradientLabel.swift
Last active May 27, 2019 09:15
Gradient color for label
// Label oluşturup gradient view'umuza ekliyoruz.
let gradientLabel = UILabel(frame: view.bounds)
// Tha magic! Burada gradientLabel'ı view'a maske olarak geçiriyoruz.
view.mask = gradientLabel
gradientLabel.text = "Hello World"
gradientLabel.font = UIFont.boldSystemFont(ofSize: 30)
gradientLabel.textAlignment = .center
gradientView.addSubview(gradientLabel)
@yusufozgul
yusufozgul / authAppleID().swift
Last active June 12, 2019 14:37
Sign in with Apple
@objc func authAppleID()
{
let appleIDProvider = ASAuthorizationAppleIDProvider()
let authRequest = appleIDProvider.createRequest()
authRequest.requestedScopes = [.email, .fullName]
let authController = ASAuthorizationController(authorizationRequests: [authRequest])
authController.presentationContextProvider = self
authController.delegate = self
authController.performRequests()
@yusufozgul
yusufozgul / extension.swift
Created June 12, 2019 14:35
Sign in with Apple
extension ViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding
{
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization)
{
guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential else { return }
print("USER: \(appleIDCredential.user)")
print("EMAIL: \(appleIDCredential.email!)")
print("FULL NAME: \(appleIDCredential.fullName!)")
}
@yusufozgul
yusufozgul / viewDidLoad.swift
Created June 12, 2019 14:36
Sign in with Apple
override func viewDidLoad()
{
super.viewDidLoad()
let authButton = ASAuthorizationAppleIDButton()
authButton.addTarget(self, action: #selector(authAppleID), for: .touchUpInside)
view.addSubview(authButton)
authButton.center = view.center
}
@IBAction func error(_ sender: Any)
{
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.error)
}
@IBAction func succes(_ sender: Any)
{
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success)
@yusufozgul
yusufozgul / Calculator-SwiftUI-1.swift
Created July 10, 2019 13:05
Calculator-SwiftUI-1
var buttonsText = ["AC", "±", "%", "÷",
"7", "8", "9", "x",
"4", "5", "6", "-",
"1", "2", "3", "+",
"0", "00", ".", "="]
@State var screenValue = "0"
@yusufozgul
yusufozgul / Calculator-SwiftUI-2.swift
Last active July 10, 2019 13:23
Calculator-SwiftUI-2
var buttonsText = ["AC", "±", "%", "÷",
"7", "8", "9", "x",
"4", "5", "6", "-",
"1", "2", "3", "+",
"0", "00", ".", "="]
@State var screenValue = "0"
var calculator = Calculator()
var body: some View {
VStack { // Vertical Stack İçerisindeki elemanları yatay olarak alt alta ekler
struct ThridViewRow : View {
var city: String
var body: some View {
Text(city)
}
}
struct ThirdView : View
{
var listElement = ["Antalya", "İzmir", "İstanbul", "Ankara", "Muğla", "Çanakkale", "Bursa", "Adana"]