自定义瀑布流(可添加自定义header和footer)




github 地址github.com/Wanghongchao12138/CustomerCollectionView

/* 设置cell 的宽高 */

(CGFloat)collectionView:(UICollectionView)collectionView layout:(WHCWaterfallFlowLayout)collectionViewLayout heightForWidth:(CGFloat)width atIndexPath:(NSIndexPath*)indexPath;

/* 设置collection 的头视图的size */

(CGSize)collectionView:(UICollectionView)collectionView layout:(WHCWaterfallFlowLayout)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;

/* 设置collection footer 视图的size */

(CGSize)collectionView:(UICollectionView)collectionView layout:(WHCWaterfallFlowLayout)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section;

-- colCount --   设置CollectionView 的cell 的列数   -- sectionInset --    设置cell 的间距

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在ROS中,消息类型的头部(header)通常包含时间戳(stamp)、坐标系(frame_id)等信息。如果我们需要在自定义的ROS消息类型中添加header,可以按照以下步骤进行操作: 1. 在msg文件夹下创建一个新的.msg文件,例如MyMessage.msg。 2. 在该文件中定义消息格式,包括header和其他字段,例如: ``` Header header float32 data1 float32 data2 ``` 这里定义了一个包含header和两个浮点型数据的自定义消息类型。 3. 在CMakeLists.txt文件中添加以下代码: ``` add_message_files( FILES MyMessage.msg ) ``` 这里告诉ROS编译器要编译MyMessage.msg。 4. 在package.xml文件中添加以下代码: ``` <build_depend>message_generation</build_depend> <exec_depend>message_runtime</exec_depend> ``` 这里告诉ROS这个包依赖于消息生成器和消息运行时。 5. 在CMakeLists.txt文件中添加以下代码: ``` generate_messages( DEPENDENCIES std_msgs ) ``` 这里告诉ROS要生成消息代码,并且依赖于std_msgs。 6. 在源代码中引用自定义消息类型,例如: ``` #include "my_package/MyMessage.h" ``` 7. 在源代码中创建一个MyMessage类型的消息,并填充header和其他字段,例如: ``` my_package::MyMessage msg; msg.header.stamp = ros::Time::now(); msg.header.frame_id = "map"; msg.data1 = 1.0; msg.data2 = 2.0; ``` 这里创建了一个MyMessage类型的消息,并设置了时间戳为当前时间,坐标系为map,以及其他字段的值。 8. 在源代码中发布该消息,例如: ``` ros::Publisher pub = node_handle.advertise<my_package::MyMessage>("my_topic", 10); pub.publish(msg); ``` 这里创建了一个发布者,并将MyMessage类型的消息发布到my_topic话题上。 这样就可以在自定义的ROS消息类型中添加header了。注意,在使用header时,需要先包含std_msgs/Header头文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值