Skip to content

Instantly share code, notes, and snippets.

@anngdev
anngdev / UITextViewTouched
Created May 31, 2023 08:35
Detect UITextView character on touched (UITextView only)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label: UITextView!
@IBOutlet weak var labelOverlat: UIView!
override func viewDidLoad() {
super.viewDidLoad()
@anngdev
anngdev / heightForAttributedString
Created May 31, 2023 08:32
Swift heightForAttributedString
//For UIlabel
func heightForAttributedString(_ attributedString: NSAttributedString, width: CGFloat) -> CGFloat {
let maxSize = CGSize(width: width, height: CGFloat.greatestFiniteMagnitude)
let options: NSStringDrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading]
let boundingRect = attributedString.boundingRect(with: maxSize, options: options, context: nil)
let height = ceil(boundingRect.height)
return height
}
@anngdev
anngdev / Multicall.ts
Created May 29, 2023 14:39 — forked from m1guelpf/Multicall.ts
An Ethers.js-compatible Multicall implementation
import { ethers } from 'ethers'
import { ChainId } from '@/types/utils'
import { namehash } from 'ethers/lib/utils'
import { multicallAddresses, ZERO_ADDRESS } from '../consts'
import { Multicall as MulticallInterface, Multicall__factory } from '@/contracts'
export type Call = {
contract: {
address: string
}
@anngdev
anngdev / AdbCommands
Created June 7, 2022 16:41 — forked from Pulimet/AdbCommands
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
cc.Class({
extends: cc.Component,
properties: {
},
// use this for initialization
onLoad: function () {
}