12@property (nonatomic, strong) UIImageView *arrow;
13@property (nonatomic, readwrite, getter=isFollowing) BOOL
following;
25 self = [
super initWithFrame:CGRectZero];
39 self.layer.masksToBounds = NO;
46 action:@selector(followMePressed:)
47 forControlEvents:UIControlEventTouchUpInside];
49 self.translatesAutoresizingMaskIntoConstraints = NO;
53 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.navigine"];
54 image = [UIImage imageNamed:@"navigine_follow_me" inBundle:bundle withConfiguration:nil];
56 image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
58 self.arrow = [[UIImageView alloc] initWithImage:image];
61 self.arrow.translatesAutoresizingMaskIntoConstraints = NO;
62 self.arrow.contentMode = UIViewContentModeScaleAspectFit;
64 [
self addSubview:
self.arrow];
66 CGFloat padding = 8.0f;
68 [NSLayoutConstraint activateConstraints:@[
69 [
self.arrow.topAnchor constraintEqualToAnchor:
self.topAnchor constant:padding],
70 [
self.arrow.leadingAnchor constraintEqualToAnchor:
self.leadingAnchor constant:padding],
71 [
self.arrow.trailingAnchor constraintEqualToAnchor:
self.trailingAnchor constant:-padding],
72 [
self.arrow.bottomAnchor constraintEqualToAnchor:
self.bottomAnchor constant:-padding]
75 [
self updateAppearanceForFollowingState:NO];
78- (void)followMePressed:(UIButton *)sender {
79 self.following = !
self.isFollowing;
80 [
self updateAppearanceForFollowingState:
self.following];
83 self.onPressed(
self.isFollowing);
87- (UIImage *)defaultFollowMeImage {
88 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.navigine"];
89 return [UIImage imageNamed:@"navigine_follow_me" inBundle:bundle withConfiguration:nil];
99- (void)updateAppearanceForFollowingState:(BOOL)isFollowing {
101 UIImage *inactiveImg = c.
followMeIcon ?: [
self defaultFollowMeImage];
109 [
UIView animateWithDuration:kNCStandardAnimationDuration
111 usingSpringWithDamping:kNCSpringAnimationDamping
112 initialSpringVelocity:kNCSpringAnimationInitialVelocity
113 options:UIViewAnimationOptionCurveEaseInOut
117 self.layer.borderWidth = kNCActiveBorderWidth;
118 self.layer.borderColor = kNCBorderColor().CGColor;
119 self.backgroundColor = kNCWhiteBackgroundColor();
122 self.layer.borderWidth = 0;
123 self.backgroundColor = bgColor;