Skip to content

Instantly share code, notes, and snippets.

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

Md. Ibrahim Hassan Ibrahimhass

🏠
Working from home
View GitHub Profile
@Ibrahimhass
Ibrahimhass / IHProgressHUD.swift
Last active November 23, 2018 21:37
Singleton Code
private static let sharedView : IHProgressHUD = {
var localInstance : IHProgressHUD?
if Thread.current.isMainThread {
if IHProgressHUD.isNotAppExtension {
if let window = UIApplication.shared.delegate?.window {
localInstance = IHProgressHUD.init(frame: window?.bounds ?? CGRect.zero)
} else {
localInstance = IHProgressHUD()
}
}
@Ibrahimhass
Ibrahimhass / IHIndefiniteAnimatedView.swift
Last active November 23, 2018 21:38
SVIndefiniteAnimatedView Code for adding UIActivityIndicatorView
//MARK: - ActivityIndicatorView Functions
extension IndefiniteAnimatedView {
func removeAnimationLayer() {
for view in self.subviews {
if let activityView = view as? UIActivityIndicatorView {
activityView.removeFromSuperview()
}
}
getIndefinteAnimatedLayer().removeFromSuperlayer()
@Ibrahimhass
Ibrahimhass / IHIndefiniteAnimatedView.swift
Last active November 23, 2018 21:46
SVIndefiniteAnimatedView.m Converted Swift file
class IndefiniteAnimatedView : UIView {
private var activityIndicator : UIActivityIndicatorView?
private var strokeThickness : CGFloat?
private var strokeColor : UIColor?
private var indefinteAnimatedLayer : CAShapeLayer?
private var radius : CGFloat?
//MARK: - Setter Functions
@objc func setIndefinite(radius: CGFloat) {
@Ibrahimhass
Ibrahimhass / TileView.swift
Created December 22, 2018 19:31
Using Type Alias and Extension with helper functions
#if os(OSX)
import AppKit
public typealias View = NSView
public typealias Color = NSColor
public typealias Label = NSTextField
#else
import UIKit
public typealias View = UIView
//: Append data to linked List
extension LinkedList {
func append(_ node : Node) {
//Check for empty Linked List and assign the node to head if empty
guard head != nil else {
head = node
return
}
//: Get Node at Index
extension LinkedList {
func getNode(atPosition position: Int) -> Node? {
guard position > 0 else {
return nil
}
var counter = 1
var current = head
//: Insert Node at Index
extension LinkedList {
func insertNode(_ node: Node, at position: Int) {
guard position > 0 else {
return
}
var counter = 1
var current = head
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *logoImageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//http://swiftify.me/0ivnnp
import UIKit
class SwiftViewController: UIViewController {
@IBOutlet weak var logoImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
var logo: UIImage? = logoImageView.image
import UIKit
class SwiftViewController: UIViewController {
@IBOutlet weak var logoImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
if let logo = logoImageView.image {
let colorLessLogo = logo.withRenderingMode(.alwaysTemplate)
logoImageView.image = colorLessLogo