Skip to content

Instantly share code, notes, and snippets.

View vinhnx's full-sized avatar
🎯
focusing

Vinh Nguyen vinhnx

🎯
focusing
View GitHub Profile
@vinhnx
vinhnx / remove-bottom-line-navbar.md
Last active June 14, 2022 02:32
remove 1px bottom line of the navigation bar

If you just want to use a solid navigation bar color and have set this up in your storyboard, use this code in your AppDelegate class to remove the 1 pixel border via the appearance proxy:

Objective-C

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
                                  forBarPosition:UIBarPositionAny
                                      barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
@vinhnx
vinhnx / MyCell.swift
Created May 21, 2022 14:11 — forked from atierian/MyCell.swift
Oversimplified Example of MVVM
class MyCell: UITableViewCell {
let titleLabel = UILabel()
let subtitleLabel = UILabel()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
required init?(coder: NSCoder) { nil }
import Foundation
public protocol NetworkLoggable {
func log<T: CustomStringConvertible>(
label: String,
value: T?,
level: NetworkLogger,
function: StaticString,
line: UInt,
file: String
@vinhnx
vinhnx / uicollectionview+fade.md
Last active February 24, 2022 18:58
Collection view cell fade as scrolling effect

// reference: https://stackoverflow.com/a/42705208/1477298

You can do a lot of fun stuff to collection views. I like to subclass UICollectionViewFlowLayout. Here is an example that fades the top and the bottom of the collection view based on distance from center. I could modify it to fade only the very edges but you should figure it after you look through the code.

import UIKit

class FadingLayout: UICollectionViewFlowLayout,UICollectionViewDelegateFlowLayout {

    //should be 0<fade<1
@vinhnx
vinhnx / uicollectionview+centerPaging.md
Created June 9, 2017 09:24
Centered Paging with Preview Cells on UICollectionView

Centered Paging with Preview Cells on UICollectionView

The proposed offset is where the collection view would stop without our intervention. We peek into this area by finding its centre as proposedContentOffsetCenterX and examine our currently visible cells to see which one’s centre is closer to the centre of that area.

import UIKit
 
class CenterCellCollectionViewFlowLayout: UICollectionViewFlowLayout {
    
    var mostRecentOffset : CGPoint = CGPoint()
@vinhnx
vinhnx / remove_unused_localization.md
Last active October 31, 2021 05:33
Remove usused localizations from pods

Update 4/10/2017: updated script working with Cocoapod 1.3.1

... If you are using CocoaPods, you may want to remove unwanted localizations using the pre install script below. Modify the supported_locales array to match your supported locales and paste it into your Podfile.

Note the all lowercase

platform :ios, '9.0'
@vinhnx
vinhnx / packages.json
Created September 19, 2021 02:28
Swift Package Index
{"packages":[{"url":"https:\/\/github.com\/vinhnx\/DictionaryNestedSubscript.git","versions":[{"license":{"url":"https:\/\/github.com\/vinhnx\/DictionaryNestedSubscript\/blob\/master\/LICENSE","name":"MIT"},"defaultToolsVersion":"5.1.0","verifiedCompatibility":[{"swiftVersion":"5.1","platform":{"name":"ios"}},{"swiftVersion":"5.2","platform":{"name":"ios"}},{"swiftVersion":"5.3","platform":{"name":"ios"}},{"swiftVersion":"5.4","platform":{"name":"ios"}},{"swiftVersion":"5.5","platform":{"name":"ios"}},{"swiftVersion":"5.1","platform":{"name":"linux"}},{"swiftVersion":"5.2","platform":{"name":"linux"}},{"swiftVersion":"5.3","platform":{"name":"linux"}},{"swiftVersion":"5.4","platform":{"name":"linux"}},{"swiftVersion":"5.5","platform":{"name":"linux"}},{"swiftVersion":"5.1","platform":{"name":"macos"}},{"swiftVersion":"5.2","platform":{"name":"macos"}},{"swiftVersion":"5.3","platform":{"name":"macos"}},{"swiftVersion":"5.4","platform":{"name":"macos"}},{"swiftVersion":"5.5","platform":{"name":"macos"}},{"swift
@vinhnx
vinhnx / Mocking.swift
Created September 18, 2019 07:27
Mocking in Swift
// mocking in swift
// reference: https://www.vadimbulavin.com/real-world-unit-testing-in-swift/
struct User {}
class AuthService {
var client: HTTPClient
// init
init(_ client: HTTPClient) {
81 Different Ways to Promote Your Mobile App / Game
You’ve spent weeks/months – designing and developing your app. It takes a lot of time to get it just the way you want it, but when you launch on the App Store, you barely get any downloads/installs for it. What happened?
Consider that making an application takes a lot of time, but that’s only half of it. How you promote your app, will take you just as long (If you’re doing it right).
Tapgage has kept a close eye on the Mobile App Industry for the past year, we’ve seen great new ways to help developers promote and monetize applications. Below are over 80 different ways, tips and tricks you can use to promote your new and old apps.
1) Have a catchy Title that stands out from the rest. (Blog post )