顶部滚动菜单选项
查看次数:6836
下载次数:1407
上传时间:2016-08-15
大小:69 B
Github下载地址 https://github.com/Hanymore/SGTopScrollMenu.git
1、使用方法一:
1、将项目中SGTopScrollMenu文件夹导入工程
2、导入#import "SGTopScrollMenu.h"头文件
3、通过alloc、initWithFrame或者类方法topScrollMenuWithFrame去创建SGTopScrollMenu对象
4、遵循SGTopScrollMenuDelegate协议下topScrollMenuDelegate代理,实现Delegate方法(- (void)SGTopScrollMenu:(SGTopScrollMenu *)topScrollMenu didSelectTitleAtIndex:(NSInteger)index;)
2、使用方法二:(请参照Demo中的使用)
3、标题按钮是通过Label创建并在其上添加手势(UITapGestureRecognizer)
4、通过- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(nullable NSDictionary *)attributes context:(nullable NSStringDrawingContext *)context;方法,实现顶部标题按钮的自适应宽度
5、根据偏移量让选中标题居中
注:
自己封装了一个方便码友使用的Demo(这类的Demo很多,自己也下了几个看了看,感觉代码简单的功能不全,复杂的也不想研究。偷懒中自己封装一个简单、实用、方便的代码;为的是:方便他人,方便自己)
收藏