Skip to content

Instantly share code, notes, and snippets.

View muratyasarr's full-sized avatar
🎯
Focusing

Murat Yasar muratyasarr

🎯
Focusing
View GitHub Profile
@darrarski
darrarski / CustomIntensityVisualEffectView.swift
Last active June 27, 2024 08:45
UIVisualEffectView subclass that allows to customise effect intensity
import UIKit
final class CustomIntensityVisualEffectView: UIVisualEffectView {
/// Create visual effect view with given effect and its intensity
///
/// - Parameters:
/// - effect: visual effect, eg UIBlurEffect(style: .dark)
/// - intensity: custom intensity from 0.0 (no effect) to 1.0 (full effect) using linear scale
init(effect: UIVisualEffect, intensity: CGFloat) {
theEffect = effect
@ajself
ajself / rotatable.swift
Last active May 27, 2024 12:11
Rotate UIViewControllers that conform to a protocol
/*
This is an update to an example found on http://www.jairobjunior.com/blog/2016/03/05/how-to-rotate-only-one-view-controller-to-landscape-in-ios-slash-swift/
The code there works, with some updating to the latest Swift, but the pattern isn't very Swifty. The following is what I found to be more helpful.
*/
/*
First, create a protocol that UIViewController's can conform to.
This is in opposition to using `Selector()` and checking for the presence of an empty function.
*/
@chriseidhof
chriseidhof / tableviews.swift
Last active October 15, 2023 20:56
trySwift
import UIKit
// If you enjoyed this talk (video link will be up soon), then you might also enjoy our book Advanced Swift: http://www.objc.io/books/advanced-swift
struct Person {
let name: String
let city: String
}
let people = [
@thomaskioko
thomaskioko / UITextFiledIcon.swift
Last active January 23, 2020 14:52
Sample code showing how to add icons to UITextFields
class SignInViewController: UIViewController {
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
//set the label font style
instagramLabel.font = UIFont(name: "Pacifico", size: 50)
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let showAlertButton = UIButton(type: UIButtonType.Custom)
showAlertButton.frame = CGRectMake(0, 0, 100, 40)
showAlertButton.setTitle("Show Alert", forState: .Normal)
@coryalder
coryalder / UIImage+Invert.swift
Created March 12, 2015 05:42
Invert a UIImage at runtime using Core Image CIFilter + CIContext
extension UIImage {
func invertedImage() -> UIImage? {
let img = CoreImage.CIImage(CGImage: self.CGImage)
let filter = CIFilter(name: "CIColorInvert")
filter.setDefaults()
filter.setValue(img, forKey: "inputImage")
@rcullito
rcullito / gist:cd4513766e112387b9c8
Created May 6, 2014 01:51
ElasticSearch Fuzzy Query, Favor Exact Matches
{
"query": {
"bool": {
"should": [
{
"match": {
"_all": search_term
}
},
{
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {