Skip to content

Instantly share code, notes, and snippets.

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

Yunus Tek yunustek

🏠
Working from home
View GitHub Profile
@yunustek
yunustek / keybase.md
Created April 16, 2021 19:29
keybase.md

Keybase proof

I hereby claim:

  • I am yunustek on github.
  • I am ynsios (https://keybase.io/ynsios) on keybase.
  • I have a public key ASBW2Szwi-x0-ttNXWabyyvsPX__SyOtMcW69A_shHrSdAo

To claim this, I am signing this object:

@yunustek
yunustek / TrapezoidView
Created August 22, 2019 22:33
Trapezoid View
final class TrapezoidView: UIView {
@IBInspectable
var isLeft: Bool = true {
didSet{
self.initialize()
}
}
@IBInspectable
var color: UIColor = .white {
@yunustek
yunustek / CodableInheritanceClasses.playground
Last active April 25, 2019 07:48
Use Json Codable Inheritance Classes
import UIKit
open class BaseModel : Codable {
var deviceName: String?
private enum CodingKeys: String, CodingKey { case deviceName }
init() { }
public func encode(to encoder: Encoder) throws {
@yunustek
yunustek / openAppWithUrlScheme.swift
Last active January 29, 2019 15:05
Open Application with url scheme in iOS
@IBAction func faceButtonPressed(_ sender: Any) {
let accountID: String = "1235121234"
if let url = URL(string: "fb://profile/\(accountID)"), UIApplication.shared.canOpenURL(url) {
self.openUrl(url: url)
} else if let url = URL(string: "https://www.facebook.com/\(accountName)"), UIApplication.shared.canOpenURL(url) {
self.openUrl(url: url)
}
}
func configureAccessibility(_ account: Account) {
photoButton.isAccessibilityElement = true
usernameLabel.isAccessibilityElement = true
pointButton.isAccessibilityElement = true
photoButton.accessibilityTraits = .button
usernameLabel.accessibilityTraits = .staticText
pointButton.accessibilityTraits = .button
//Point Button
func configureAccessibility(_ account: Account) {
photoButton.isAccessibilityElement = true
usernameLabel.isAccessibilityElement = true
pointButton.isAccessibilityElement = true
photoButton.accessibilityTraits = .button
usernameLabel.accessibilityTraits = .staticText
pointButton.accessibilityTraits = .button
}
func configureAccessibility(_ account: Account) {
photoButton.isAccessibilityElement = true
usernameLabel.isAccessibilityElement = true
pointButton.isAccessibilityElement = true
}
class AccountViewController: UIViewController {
@IBOutlet var photoButton: UIButton!
@IBOutlet var usernameLabel: UILabel!
@IBOutlet var pointButton: UIButton!
@yunustek
yunustek / NotificationService-didReceive-updated.swift
Created December 5, 2018 12:31
NotificationService-didReceive-updated
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
guard let bestAttemptContent = bestAttemptContent, // 1. bestAttemptContent nil olmadığına emin ol
let apsData = bestAttemptContent.userInfo["aps"] as? [String: Any], // 2. Payload dan aps'i al
let attachmentURLAsString = apsData["mediaUrl"] as? String, // 3. mediaUrl'i al
let attachmentURL = URL(string: attachmentURLAsString) else { // 4. String'i URL'e çevir
return
}
@yunustek
yunustek / DownloadImageFunc.m
Created December 5, 2018 12:21
DownloadImageFunc
/// Bir görüntüyü indirmek ve bir bildirimde sunmak için bu işlevi kullanın
/// - Parametereler:
/// - url: Resmin url'i
/// - completion: Görüntüyü, sonuç olarak UNNotificationAttachment biçiminde döndür
private func downloadImageFrom(url: URL, with completionHandler: @escaping (UNNotificationAttachment?) -> Void) {
let task = URLSession.shared.downloadTask(with: url) { (downloadedUrl, response, error) in
// 1. Url yoksa nil gönder ve geri dön
guard let downloadedUrl = downloadedUrl else {
completionHandler(nil)
return