Skip to content

Instantly share code, notes, and snippets.

View ham118's full-sized avatar
🎯
Focusing

Harsh M. ham118

🎯
Focusing
View GitHub Profile
@ham118
ham118 / SetCustomUISliderHeight.swift
Last active June 24, 2024 02:19
To set customize UISlider height | Swift 4
//To set UISlider height, (which is by default not provided by UIKit framework)
//Steps:
//1. Add "CustomSlider" class in your swift file.
//2. Set "CustomSlider" class name into UISlider control from interface builder.
//3. Set "trackLineHeight" value as per requirment.
class CustomSlider: UISlider {
//Set line height value from Interface Builder,i.e. here ten is default value
@IBInspectable var trackLineHeight: CGFloat = 10
@ham118
ham118 / EvaluatingJavaScript.swift
Last active May 5, 2023 08:07
EvaluatingJavaScript : This is gist to change font size and avoid text copy functionality from entire html in UIWebView | Swift 5
//This is code to change font size and avoid text copy functionality from entire html in UIWebView
//"textSize" : this is integer variable which you want to set font size
func webViewDidFinishLoad(_ webView: UIWebView) {
if (webView.stringByEvaluatingJavaScript(from: "document.readyState") == "complete") {
//Avoid to detect touch gesture for disable user selection
webView.stringByEvaluatingJavaScript(from: "document.documentElement.style.webkitUserSelect='none';")
webView.stringByEvaluatingJavaScript(from: "document.documentElement.style.webkitTouchCallout='none';")
//Set font size
let jsString = "document.getElementsByTagName('body')[0].style.fontSize='\(textSize)px'"
@ham118
ham118 / ScrollAtTextField.txt
Last active November 22, 2019 10:14
This is the class for show/hide keyboard and accordingly scrolls scrollView with multiple textfield | Swift 4
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
//MARK: - Variables
var activeField: UITextField?
//---------------------------------
//MARK: - IBOutlets
@IBOutlet weak var firstTextField: UITextField!