Skip to content

Instantly share code, notes, and snippets.

View musakokcen's full-sized avatar

musa kokcen musakokcen

View GitHub Profile
@tijme
tijme / UITextViewPlaceholder.swift
Last active May 31, 2024 11:05
The correct way to implement a placeholder in a UITextView (Swift)
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Copyright (c) 2017 Tijme Gommers <tijme@finnwea.com>
//
// 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
@pkuecuekyan
pkuecuekyan / WKWebViewSizeToFit.swift
Last active June 17, 2024 17:44
Adjust height of WKWebView frame based on scrollHeight of the webView's content
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to
// match the height of the content's scrollHeight
//
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if webView.isLoading == false {
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
if let height = result as? CGFloat {
@alexmx
alexmx / table-view-fill-footer.m
Created April 7, 2017 13:30
Adjust UITableView footer view to fill the whole remaining part of the screen.
@breeno
breeno / CompositionalTwoColumnWaterfall.swift
Last active October 31, 2022 12:57
Simple take on a compositional layout with 2 column variable height items waterfall
import UIKit
class ViewController: UIViewController {
enum Section {
case main
}
struct Item: Hashable {
let height: CGFloat