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 {
100 self.following = isFollowing;
103 UIImage *inactiveImg = c.
followMeIcon ?: [
self defaultFollowMeImage];
111 [
UIView animateWithDuration:kNCStandardAnimationDuration
113 usingSpringWithDamping:kNCSpringAnimationDamping
114 initialSpringVelocity:kNCSpringAnimationInitialVelocity
115 options:UIViewAnimationOptionCurveEaseInOut
119 self.layer.borderWidth = kNCActiveBorderWidth;
120 self.layer.borderColor = kNCBorderColor().CGColor;
121 self.backgroundColor = kNCWhiteBackgroundColor();
124 self.layer.borderWidth = 0;
125 self.backgroundColor = bgColor;