iOS 实现一个简单的标签式顶部导航View,仿头条网易等样式

直接上可实现的需求:

1.多种属性可编辑
2.标签按钮可回调控制页面
3.页面切换可控制对应标签变化

摘要说明

多种属性可动态设置

/**
 *  标签文字颜色_未选中时
 */
@property (nonatomic, strong) UIColor * tagTextColor_normal;
/**
 *  标签文字颜色_选中时
 */
@property (nonatomic, strong) UIColor * tagTextColor_selected;
/**
 *  标签文字颜色_未选中时
 */
@property (nonatomic, assign)CGFloat tagTextFont_normal;
/**
 *  标签文字颜色_选中时
 */
@property (nonatomic, assign)CGFloat tagTextFont_selected;
/**
 *  滑块颜色
 */
@property (nonatomic, strong)UIColor *sliderColor;
/**
 *  滑块宽度
 */
@property (nonatomic, assign)CGFloat sliderW;
/**
 *  滑块高度
 */
@property (nonatomic, assign)CGFloat sliderH;

通过此代理方法可获取标签点击事件和第几个

@protocol RPTaggedNavViewDelegate <NSObject>

- (void)haveSelectedIndex:(NSInteger )index;

@end

此方法为通知view应该让哪个标签被点亮

- (void)selectingOneTagWithIndex:(NSInteger )index;
演示gif

gif_RPTaggedNavView.gif

github 地址: https://github.com/RollingPin/RPTaggedNavView

搞定. 欢迎大家指正

猜你喜欢

转载自blog.csdn.net/RollingPin/article/details/81536755
今日推荐