Skip to content

Instantly share code, notes, and snippets.

View SaladDays831's full-sized avatar
🇺🇦

Danylo SaladDays831

🇺🇦
  • Ukraine, Kyiv
  • 12:54 (UTC +03:00)
View GitHub Profile
@LeeKahSeng
LeeKahSeng / KeychainHelper.swift
Last active June 19, 2024 19:59
Swift simple keychain helper class for iOS and macOs
// MIT License
//
// Copyright (c) 2023 Lee Kah Seng
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@iOSDigital
iOSDigital / gist:8379249
Created January 12, 2014 01:14
UIImage doesn't have a tint colour. UIImageView does. This little method returns a UIImage, tinted with a UIColor. It's useful for things like table icons, where the image view is read only. Means you don't have to create loads of PNGs in different colours.
-(UIImage *)imageWithTint:(UIImage *)image andTintColor:(UIColor *)tintColor {
UIImage *imageNew = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:imageNew];
imageView.tintColor = tintColor;
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 0.0);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();