Last active
June 21, 2022 18:06
-
-
Save NSExceptional/1c641e3a371a58db27ed0a2b2af7df6a to your computer and use it in GitHub Desktop.
Vote Control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "VoteControl.h" | |
@interface _VoteControl : UIStepper @end | |
@implementation _VoteControl | |
- (instancetype)initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self) { | |
self.wraps = YES; | |
self.continuous = NO; | |
[self setDecrementImage:[UIImage systemImageNamed:@"arrow.left"] forState:UIControlStateNormal]; | |
[self setIncrementImage:[UIImage systemImageNamed:@"arrow.right"] forState:UIControlStateNormal]; | |
self.translatesAutoresizingMaskIntoConstraints = NO; | |
self.transform = CGAffineTransformRotate(self.transform, M_PI_2); | |
// self.backgroundColor = UIColor.blueColor; | |
} | |
return self; | |
} | |
@end | |
@interface VoteControl () | |
@property (nonatomic, readonly) _VoteControl *control; | |
@end | |
@implementation VoteControl | |
- (instancetype)initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if (self) { | |
_control = [_VoteControl new]; | |
[self addSubview:_control]; | |
// self.backgroundColor = UIColor.greenColor; | |
[NSLayoutConstraint activateConstraints:@[ | |
[_control.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], | |
[_control.centerYAnchor constraintEqualToAnchor:self.centerYAnchor], | |
[self.widthAnchor constraintEqualToAnchor:_control.heightAnchor], | |
[self.heightAnchor constraintEqualToAnchor:_control.widthAnchor], | |
]]; | |
} | |
return self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks /u/flying-insect!