Skip to content

Instantly share code, notes, and snippets.

@jayrhynas
Created February 15, 2024 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayrhynas/8a82053886366a9ba770d2ddb2627354 to your computer and use it in GitHub Desktop.
Save jayrhynas/8a82053886366a9ba770d2ddb2627354 to your computer and use it in GitHub Desktop.
//
// UIButton+Deprecations.h
// Medly
//
// Created by Jayson Rhynas on 2023-03-02.
// Copyright © 2023 Medly Labs Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIButton (Deprecations)
@property BOOL _deprecated_adjustsImageWhenHighlighted;
@property BOOL _deprecated_adjustsImageWhenDisabled;
@property UIEdgeInsets _deprecated_contentEdgeInsets;
@property UIEdgeInsets _deprecated_titleEdgeInsets;
@property UIEdgeInsets _deprecated_imageEdgeInsets;
@end
NS_ASSUME_NONNULL_END
//
// UIButton+Deprecations.m
// Medly
//
// Created by Jayson Rhynas on 2023-03-02.
// Copyright © 2023 Medly Labs Inc. All rights reserved.
//
#import "UIButton+Deprecations.h"
@implementation UIButton (Deprecations)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (BOOL)_deprecated_adjustsImageWhenHighlighted {
return self.adjustsImageWhenHighlighted;
}
- (void)set_deprecated_adjustsImageWhenHighlighted:(BOOL)adjust {
self.adjustsImageWhenHighlighted = adjust;
}
- (BOOL)_deprecated_adjustsImageWhenDisabled {
return self.adjustsImageWhenDisabled;
}
- (void)set_deprecated_adjustsImageWhenDisabled:(BOOL)adjust {
self.adjustsImageWhenDisabled = adjust;
}
- (UIEdgeInsets)_deprecated_contentEdgeInsets {
return self.contentEdgeInsets;
}
- (void)set_deprecated_contentEdgeInsets:(UIEdgeInsets)insets {
self.contentEdgeInsets = insets;
}
- (UIEdgeInsets)_deprecated_titleEdgeInsets {
return self.titleEdgeInsets;
}
- (void)set_deprecated_titleEdgeInsets:(UIEdgeInsets)insets {
self.titleEdgeInsets = insets;
}
- (UIEdgeInsets)_deprecated_imageEdgeInsets {
return self.imageEdgeInsets;
}
- (void)set_deprecated_imageEdgeInsets:(UIEdgeInsets)insets {
self.imageEdgeInsets = insets;
}
#pragma clang diagnostic pop
@end
//
// UIButton+Deprecations.swift
// Medly
//
// Created by Jayson Rhynas on 2023-03-02.
// Copyright © 2023 Medly Labs Inc. All rights reserved.
//
import UIKit
extension UIButton {
class Deprecations {
fileprivate var button: UIButton
fileprivate init(button: UIButton) {
self.button = button
}
var adjustsImageWhenHighlighted: Bool {
get { button._deprecated_adjustsImageWhenHighlighted }
set { button._deprecated_adjustsImageWhenHighlighted = newValue }
}
var adjustsImageWhenDisabled: Bool {
get { button._deprecated_adjustsImageWhenDisabled }
set { button._deprecated_adjustsImageWhenDisabled = newValue }
}
var contentEdgeInsets: UIEdgeInsets {
get { button._deprecated_contentEdgeInsets }
set { button._deprecated_contentEdgeInsets = newValue }
}
var titleEdgeInsets: UIEdgeInsets {
get { button._deprecated_titleEdgeInsets }
set { button._deprecated_titleEdgeInsets = newValue }
}
var imageEdgeInsets: UIEdgeInsets {
get { button._deprecated_imageEdgeInsets }
set { button._deprecated_imageEdgeInsets = newValue }
}
}
var deprecated: Deprecations {
Deprecations(button: self)
}
}
@jayrhynas
Copy link
Author

Usage:

button.deprecated.titleEdgeInsets = UIEdgeInsets(top: 0, left: 2, bottom: 0, right: -10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment