一个 UIButton 子类,模仿了 iOS 7 上 Instagram 中的 Follow 按钮。
如果您正在使用 CocoaPods,只需将以下行添加到您的 Podfile:
pod 'MPSFollowButton'
使用 MPSFollowButton 非常简单。您只需要创建一个,将其添加到您的视图中,然后切换不同的状态。
更多示例,请查看此处仓库中的示例项目,如果您发现任何问题,请提交 issue。
To toggle one of the states use one of the following methods on an instance of a MPSFollowButton.
- (void)setFollow;
- (void)setFollowWithText:(NSString *)titleLabelText;
- (void)setFollowing;
- (void)setFollowingWithText:(NSString *)titleLabelText;
- (void)setLoading;
- (void)setLoadingWithText:(NSString *)titleLabelText;
MPSFollowButton 可以通过多种方式定制。您可以为正常和选中状态自定义按钮的前景和背景颜色
@property (nonatomic, strong) UIColor *followBackgroundColor;
@property (nonatomic, strong) UIColor *followingBackgroundColor;
@property (nonatomic, strong) UIColor *loadingBackgroundColor;
@property (nonatomic, strong) UIColor *followForegroundColor;
@property (nonatomic, strong) UIColor *followingForegroundColor;
@property (nonatomic, strong) UIColor *loadingForegroundColor;
感谢 Instagram 提供灵感 :)
查看 LICENSE。