Skip to content

Instantly share code, notes, and snippets.

View Coder-ACJHP's full-sized avatar
📱
Ready for a new iOS challenge

Onur Işık Coder-ACJHP

📱
Ready for a new iOS challenge
View GitHub Profile
@Coder-ACJHP
Coder-ACJHP / Example.swift
Created July 11, 2023 07:42
Read, Update, Delete keys from keychain in swift
// Save into keychain
let nameData = Data(weparents_auth.utf8)
let passwordData = Data(weparents_PI.utf8)
KeychainHelper.shared.save(nameData, service: .userName, account: .account)
KeychainHelper.shared.save(passwordData, service: .password, account: .account)
// Read from keychain
if let nameData = KeychainHelper.shared.read(service: .userName, account: .account),
let passwordData = KeychainHelper.shared.read(service: .password, account: .account),
let nameString = String(data: nameData, encoding: .utf8),
@Coder-ACJHP
Coder-ACJHP / SplitMirror.swift
Last active March 14, 2022 12:17
SplitMirror filter with UIGraphics applied on UIImage
//
// SplitMirror filter.swift
// Image Editor
//
// Created by Coder ACJHP on 25.02.2022.
//
// SnapChat & Tiktok & Motion App like image filter
// Inspired from 'https://support.apple.com/tr-tr/guide/motion/motn169f94ea/mac'
// Splits an image in half vertically and reverses the left remaining half to create a reflection.
@Coder-ACJHP
Coder-ACJHP / CreateVideo.swift
Last active August 26, 2021 06:58
This code creating MPEG4 video with multiple small video parts from given UIImage array and then merging all of video parts into one and save it in user library
@IBAction func onApply(_ sender: Any) {
if selectedAssetInfo.isEmpty {
return
}
var tempVideoURLs: Array<URL> = []
waiting.startAnimating()
waiting.isHidden = false
@Coder-ACJHP
Coder-ACJHP / Draw3Dtext.swift
Last active March 9, 2021 16:58
With this function you can draw 3D text in Core graphics api in swift
// Original code in obj-c = https://stackoverflow.com/questions/13766268/3d-text-effect-in-ios
private func draw3D(text: NSString, usingfont font: UIFont, depthValue depth: CGFloat, foregroundColor: UIColor, shadowColor: UIColor, outlineColor: UIColor) -> UIImage? {
let attributes: [NSAttributedString.Key: Any] = [
.font : font,
.foregroundColor : foregroundColor
]
var textSize = view.bounds.size
textSize.width += depth + 5
textSize.height += depth + 5
@Coder-ACJHP
Coder-ACJHP / DrawCircularText.swift
Created January 22, 2021 14:25
This function is let you draw text around circle.
/// This function drawing text around circle path and its percentage depends on 'bendFactor'
/// - Parameters:
/// - text: String for drawing
/// - bend: value of circle percentage it should be between -2.0 and 2.0
/// - size: Your container view size that you want to draw on it
/// - clockWise: Text should start from where clockWise or anticlockwise
private func drawCurved(text: String, bendFactor bend: CGFloat, fitToSize size: CGSize, clockWise: Bool = true) {
var tempTextRef: String = text
if text.count > maximumCharacterLimit {
@Coder-ACJHP
Coder-ACJHP / Connectivity.swift
Created August 13, 2020 15:24
Network connectivity checker, It can be used instead of Reachability.swift
//
// Connectivity.swift
// Test App
//
// Created by Onur Işık on 14.05.2020.
// Copyright © 2020 Onur Işık. All rights reserved.
//
// NOTE: This struct needs to Alomafire pod to work (Alomafire includes NetworkReachabilityManager)
@Coder-ACJHP
Coder-ACJHP / UpdateRGBColors.swift
Created July 17, 2020 09:21
Change rgb colors of UIImage with given multipliers [0-2]
/// Update image RGB colors with sliders
public func updateImageColorsWith(multiplier: [CGFloat], of: UIImage) -> UIImage {
guard let inputCGImage = of.cgImage else {
print("Unable to get cgImage")
return of
}
let colorSpace = CGColorSpaceCreateDeviceRGB()
let width = inputCGImage.width
@Coder-ACJHP
Coder-ACJHP / AnimationView.swift
Created April 1, 2020 00:41
UIView includes floating hearts like facebook live streams animation
//
// AnimationView.swift
// autofix
//
// Created by Onur Işık on 31.03.2020.
// Copyright © 2020 Coder ACJHP. All rights reserved.
//
import UIKit
@Coder-ACJHP
Coder-ACJHP / DrawFaceRect.swift
Created November 29, 2019 07:47
Draw face rectangle on UIView by converting and transforming from UIGraphics coordinate to UIView coordinates with sample buffer in Swift 4.2
private func drawFaceRectangle(sampleBuffer: CMSampleBuffer, detectedFaceRect: CGRect) {
let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
let cameraImage = CIImage(cvPixelBuffer: pixelBuffer!)
// For converting the Core Image Coordinates to UIView Coordinates
let ciImageSize = cameraImage.extent.size
var transform = CGAffineTransform(scaleX: 1, y: -1)
transform = transform.translatedBy(x: 0, y: -ciImageSize.height)
@Coder-ACJHP
Coder-ACJHP / DrawFaceRectFromSampleBuffer.swift
Created November 20, 2019 07:34
This method gets sample buffer and converts it to image than draws face rect on shape layer on UIKit
fileprivate func drawFaceFrame(sampleBuffer: CMSampleBuffer) {
let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
let cameraImage = CIImage(cvPixelBuffer: pixelBuffer!)
let faces = faceDetector?.features(in: cameraImage)
// For converting the Core Image Coordinates to UIView Coordinates
let ciImageSize = cameraImage.extent.size
var transform = CGAffineTransform(scaleX: 1, y: -1)