Skip to content

Instantly share code, notes, and snippets.

View dasdom's full-sized avatar

Dominik Hauser dasdom

View GitHub Profile
{
"basics": {
"name": "Dominik Hauser",
"label": "iOS developer",
"picture": "https://xcode.tips/assets/avatar.png",
"email": "[email protected]",
"phone": "",
"website": "https://dasdom.dev",
"summary": "I started iOS development in 2009. Since then I have worked in several companies in Germany. In my spare time I write books about Test-Driven iOS development and having fun with iOS development.\n\nEven though I mostly worked in agencies, I enjoy most working on a product over a long time.",
"location": {
struct ConverterView: View {
private var units = ["J", "MeV", "kWh", "kpm", "kcal", "erg"]
@State var input: String = "Input"
@State var output: String = "Result"
@State private var selectedInputIndex = 0
@State private var selectedOutputIndex = 0
var body: some View {
VStack {
import UIKit
class TableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.rowHeight = UITableViewAutomaticDimension
let duration = 0.5.tweak("Animation/Duration", min: 0, max: 5)
let delay = 0.1.tweak("Animation/Delay", min: 0, max: 1)
let damping = CGFloat(0.6.tweak("Animation/Damping", min: 0, max: 1))
let springVelocity = CGFloat(0.0.tweak("Animation/Spring Velocity", min: 0, max: 10))
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
labelTopConstraint.constant = -40
labelUsernameConstraint.constant = -40
usernamePasswordConstraint.constant = -40
passwordButtonConstraint.constant = -40
}
override func viewDidAppear(_ animated: Bool) {
@IBOutlet weak var labelTopConstraint: NSLayoutConstraint!
@IBOutlet weak var labelUsernameConstraint: NSLayoutConstraint!
@IBOutlet weak var usernamePasswordConstraint: NSLayoutConstraint!
@IBOutlet weak var passwordButtonConstraint: NSLayoutConstraint!
@dasdom
dasdom / preprocessor_fun.h
Last active August 26, 2015 09:34 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@dasdom
dasdom / uiappearance-selector.md
Last active August 29, 2015 14:26 — forked from mattt/uiappearance-selector.md
A list of methods and properties conforming to `UIAppearance` as of iOS 8.0

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'

UIActivityIndicatorView

@dasdom
dasdom / gist:c323ef1ccdc52a8ca563
Last active August 29, 2015 14:26
Variable-height UITableView tableHeaderView with autolayout
// in a UITableViewController (or any other view controller with a UITableView)
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, 0)];
header.translatesAutoresizingMaskIntoConstraints = NO;
// [add subviews and their constraints to header]
NSLayoutConstraint *headerWidthConstraint = [NSLayoutConstraint
import UIKit
@objc protocol TransitionInfoProtocol {
var view: UIView! { get set }
func viewsToAnimate() -> [UIView]
func copyForView(subView: UIView) -> UIView
optional func frameForView(subView: UIView) -> CGRect
}