Skip to content

Instantly share code, notes, and snippets.

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

Furkan furkanerkorkmaz

🏠
Working from home
View GitHub Profile
@kevinjbayer
kevinjbayer / html_strings.swift
Last active October 16, 2023 21:22
Render HTML strings in SwiftUI
//
// ContentView.swift
// Animations
//
// Created by Kevin Bayer on 4/5/21.
//
import SwiftUI
struct ContentView: View {
@amfathi
amfathi / BaseCollectionViewCell.swift
Last active July 15, 2022 10:35
**Base** Views and Controllers (SnapKit + RxSwift)
import UIKit
class BaseCollectionViewCell: UICollectionViewCell, Identifiable {
override init(frame: CGRect) {
super.init(frame: .zero)
setupViews()
setupConstraints()
}
/// NavigationTitleDropDownButton
class NavigationTitleDropDownButton: UIButton {
/// Variable Declaration(s)
var lblTitle: UILabel = {
var lbl: UILabel = UILabel()
lbl.translatesAutoresizingMaskIntoConstraints = false
lbl.backgroundColor = .clear
lbl.textAlignment = .center
lbl.adjustsFontSizeToFitWidth = true
// without turtle drawing a hexagon is math heavy and not trivial to modify
let numberOfSides: CGFloat = 6
let radiusOuterCircle: CGFloat = bounds.width
let sideLength = radiusOuterCircle / 2
let theta = (CGFloat.pi * 2) / numberOfSides
let centerX = sideLength / 2
let centerY = sideLength / 2
let initialPoint = CGPoint(x: radiusOuterCircle * cos(2 * CGFloat.pi * 0/numberOfSides + theta) + centerX, y: radiusOuterCircle * sin(2 * CGFloat.pi * 0/numberOfSides + theta) + centerY)
[
{
"il": "Adana",
"plaka": 1,
"ilceleri": [
"Aladağ",
"Ceyhan",
"Çukurova",
"Feke",
"İmamoğlu",
@fe9lix
fe9lix / remove_swift_headers.sh
Created February 16, 2016 19:08
Xcode: Remove header comments in Swift files
find . -type f -name "*.swift" -not -path "./Pods/*" -exec sed -i '' -e '1,/^import/{/^\/\/.*/d;}' -e '/./,$!d' {} \;
@tkersey
tkersey / UIView.swift
Created November 16, 2015 01:12
Calculate preferred height of UIView
extension UIView {
func calculatePreferredHeight(preferredWidth: CGFloat? = nil) -> CGFloat {
let width = preferredWidth ?? frame.width
let widthConstraint = NSLayoutConstraint.constraintsWithVisualFormat("H:[view(==\(width)@999)]", options: .allZeros, metrics: nil, views: ["view": self])
addConstraints(contraint)
let height = systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
removeConstraints(constraint)
return height
}
}
@billyto
billyto / localized2JSON.swift
Last active June 13, 2023 17:32
convert localizable.string files to json format
#!/usr/bin/env swift
//FIRST: chmod +x localized2JSON.swift
//USE: ./localize-strings2json.swift localizable.strings strings.json
//TODO: error checking for parameters and files
//TODO: --help -h
//TODO: separate groups of string in dictionaries?
import Foundation
@muukii
muukii / Drawrect Animation
Created February 10, 2014 13:08
Drawrect Animation
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
[super setHighlighted:highlighted];
[self setNeedsDisplay];
if (animated) {
[UIView transitionWithView:self duration:0.1
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[self.layer displayIfNeeded];
} completion:nil];
}