Skip to content

Instantly share code, notes, and snippets.

View leoiphonedev's full-sized avatar

Aman Aggarwal leoiphonedev

View GitHub Profile
@leoiphonedev
leoiphonedev / WKWebViewDemo-VC-Step5.swift
Created August 11, 2018 13:57
Loading web page to WKWebView
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
activityIndicator.startAnimating()
activityIndicator.hidesWhenStopped = true
let urlString = "http://www.apple.com"
let request = URLRequest(url: URL(string: urlString)!)
self.webView.load(request)
}
@leoiphonedev
leoiphonedev / WKWebViewDemo-VC-Step1.swift
Created August 11, 2018 13:40
Creating IBOUtlet for WKWebView and UIActiVityIndicatorView
//
// ViewController.swift
// WKWEbView-Demo
//
// Created by iosTutorialJunction.com on 10/08/18.
// Copyright © 2018 iosTutorialJunction.com. All rights reserved.
//
import UIKit
import WebKit
@leoiphonedev
leoiphonedev / ViewController-Pulse-Animation-Complete-Code.swift
Created August 5, 2018 10:25
Complet source code for creating pulse animation
//
// ViewController.swift
// PulseAnimation
//
// Created by iostutorialjunction.com on 15/07/18.
// Copyright © 2018 iostutorialjunction.com. All rights reserved.
//
import UIKit
@leoiphonedev
leoiphonedev / ViewController-Pulse-Animation-Call-Animate-Function-using-asyncAfter.swift
Created August 5, 2018 10:18
Call animatePulsatingLayerAt function after little delay
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: {
self.animatePulsatingLayerAt(index: 0)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4, execute: {
self.animatePulsatingLayerAt(index: 1)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
self.animatePulsatingLayerAt(index: 2)
})
})
})
func animatePulsatingLayerAt(index:Int) {
//Giving color to the layer
pulseArray[index].strokeColor = UIColor.darkGray.cgColor
//Creating scale animation for the layer, from and to value should be in range of 0.0 to 1.0
// 0.0 = minimum
//1.0 = maximum
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimation.fromValue = 0.0
@leoiphonedev
leoiphonedev / ViewController-Pulse-Animation-Step8.swift
Last active August 5, 2018 09:40
Creatig pulse layer so that we can animate it like pulse animation
func createPulse() {
for _ in 0...2 {
let circularPath = UIBezierPath(arcCenter: .zero, radius: UIScreen.main.bounds.size.width/2.0, startAngle: 0, endAngle: 2 * .pi, clockwise: true)
let pulseLayer = CAShapeLayer()
pulseLayer.path = circularPath.cgPath
pulseLayer.lineWidth = 2.0
pulseLayer.fillColor = UIColor.clear.cgColor
pulseLayer.lineCap = kCALineCapRound
pulseLayer.position = CGPoint(x: imgvAvatar.frame.size.width/2.0, y: imgvAvatar.frame.size.width/2.0)
imgvAvatar.layer.addSublayer(pulseLayer)
@leoiphonedev
leoiphonedev / ViewController-Pulse-Animation-Step7.swift
Created July 22, 2018 15:53
Making avatar imageview as circular
//
// ViewController.swift
// PulseAnimation
//
// Created by iostutorialjunction.com on 15/07/18.
// Copyright © 2018 iostutorialjunction.com. All rights reserved.
//
import UIKit
@leoiphonedev
leoiphonedev / ViewController-Pulse-Animation.swift
Created July 22, 2018 15:29
Creating IBOutlet for UIImageView
@IBOutlet weak var imgvAvatar: UIImageView!
@leoiphonedev
leoiphonedev / CircularProgress.swift
Created May 18, 2018 10:08
Writing initwithframe and initwithcoder functions
//
// CircularProgress.swift
// CircularProgress-Tutorial
//
// Created by Aman Aggarwal on 5/18/18.
// Copyright © 2018 iostutorialjunction.com . All rights reserved.
//
import UIKit
@leoiphonedev
leoiphonedev / CircularProgress.swift
Created May 18, 2018 09:35
How to use CircularProgress.swift as circularprogress view in ViewController
//
// ViewController.swift
// CircularProgress-Tutorial
//
// Created by Aman Aggarwal on 5/18/18.
// Copyright © 2018 iostutorialjunction.com. All rights reserved.
//
import UIKit