iOS 图标和文字自定按钮

news/2024/4/19 6:06:44/文章来源:https://blog.csdn.net/u010545480/article/details/128099573

在项目开发中,经常需要用到按钮,系统默认的按钮是图标在左边,标题在右边。但往往实际情况是多变的,有时候图标在右边、有时候图标在上面,这个时候系统的按钮往往无法满足需求,所以我们需要自定义按钮来满足需求的开发。下面提供两种方法来实现按钮图标和文字自定按钮。

一、采用添加分类,利用EdgeInsets属性实现

创建一个UIButton的分类,文件名为:UIButton+Icon,在分类里添加如下代码:

1.1 UIButton+Icon.h

#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGINtypedef NS_ENUM(NSUInteger, HSButtonEdgeInsetsStyle) {HSButtonEdgeInsetsStyleTop, // image在上,label在下HSButtonEdgeInsetsStyleLeft, // image在左,label在右HSButtonEdgeInsetsStyleBottom, // image在下,label在上HSButtonEdgeInsetsStyleRight // image在右,label在左
};@interface UIButton (Icon)- (void)layoutEdgeInsetsStyle:(HSButtonEdgeInsetsStyle)style space:(CGFloat)space;@endNS_ASSUME_NONNULL_END

1.2 UIButton+Icon.m

#import "UIButton+Icon.h"@implementation UIButton (Icon)- (void)layoutEdgeInsetsStyle:(HSButtonEdgeInsetsStyle)style space:(CGFloat)space {CGFloat imageWith = self.imageView.frame.size.width;CGFloat imageHeight = self.imageView.frame.size.height;CGFloat labelWidth = self.titleLabel.frame.size.width;CGFloat labelHeight = self.titleLabel.frame.size.height;UIEdgeInsets imageEdgeInsets = UIEdgeInsetsZero;UIEdgeInsets labelEdgeInsets = UIEdgeInsetsZero;switch (style) {case HSButtonEdgeInsetsStyleTop:{imageEdgeInsets = UIEdgeInsetsMake(-labelHeight-space/2.0, 0, 0, -labelWidth);labelEdgeInsets = UIEdgeInsetsMake(0, -imageWith, -imageHeight-space/2.0, 0);}break;case HSButtonEdgeInsetsStyleLeft:{imageEdgeInsets = UIEdgeInsetsMake(0, -space/2.0, 0, space/2.0);labelEdgeInsets = UIEdgeInsetsMake(0, space/2.0, 0, -space/2.0);}break;case HSButtonEdgeInsetsStyleBottom:{imageEdgeInsets = UIEdgeInsetsMake(0, 0, -labelHeight-space/2.0, -labelWidth);labelEdgeInsets = UIEdgeInsetsMake(-imageHeight-space/2.0, -imageWith, 0, 0);}break;case HSButtonEdgeInsetsStyleRight:{imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth+space/2.0, 0, -labelWidth-space/2.0);labelEdgeInsets = UIEdgeInsetsMake(0, -imageWith-space/2.0, 0, imageWith+space/2.0);}break;default: break;}self.titleEdgeInsets = labelEdgeInsets;self.imageEdgeInsets = imageEdgeInsets;
}@end

1.3 使用

#import "IconButtonController.h"
#import "UIButton+Icon.h"@interface IconButtonController ()@end@implementation IconButtonController- (void)viewDidLoad {[super viewDidLoad];self.title = @"自定义按钮";UIButton *btn1 = [[UIButton alloc] initWithFrame:CGRectMake(30, 30, SCREEN_WIDTH-60, 100)];[btn1 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn1 setTitle:@"保存完成" forState:UIControlStateNormal];[btn1.titleLabel setTextColor:[UIColor whiteColor]];[btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn1.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn1 setBackgroundColor:[UIColor orangeColor]];btn1.layer.cornerRadius = 5;btn1.layer.masksToBounds = YES;[self.view addSubview:btn1];UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(30, 160, SCREEN_WIDTH-60, 100)];[btn2 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn2 setTitle:@"保存完成" forState:UIControlStateNormal];[btn2.titleLabel setTextColor:[UIColor whiteColor]];[btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn2.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn2 setBackgroundColor:[UIColor orangeColor]];btn2.layer.cornerRadius = 5;btn2.layer.masksToBounds = YES;[self.view addSubview:btn2];UIButton *btn3 = [[UIButton alloc] initWithFrame:CGRectMake(30, 290, SCREEN_WIDTH-60, 100)];[btn3 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn3 setTitle:@"保存完成" forState:UIControlStateNormal];[btn3.titleLabel setTextColor:[UIColor whiteColor]];[btn3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn3.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn3 setBackgroundColor:[UIColor orangeColor]];btn3.layer.cornerRadius = 5;btn3.layer.masksToBounds = YES;[self.view addSubview:btn3];UIButton *btn4 = [[UIButton alloc] initWithFrame:CGRectMake(30, 420, SCREEN_WIDTH-60, 100)];[btn4 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn4 setTitle:@"保存完成" forState:UIControlStateNormal];[btn4.titleLabel setTextColor:[UIColor whiteColor]];[btn4 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn4.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn4 setBackgroundColor:[UIColor orangeColor]];btn4.layer.cornerRadius = 5;btn4.layer.masksToBounds = YES;[self.view addSubview:btn4];[btn1 layoutEdgeInsetsStyle:HSButtonEdgeInsetsStyleLeft space:5];[btn2 layoutEdgeInsetsStyle:HSButtonEdgeInsetsStyleRight space:5];[btn3 layoutEdgeInsetsStyle:HSButtonEdgeInsetsStyleTop space:5];[btn4 layoutEdgeInsetsStyle:HSButtonEdgeInsetsStyleBottom space:5];}@end

1.4 效果图

在这里插入图片描述

二、采用按钮子类,自定图标和标题位置实现

创建一个类:IconButton,继承于UIButton,添加如下代码:

2.1 IconButton.h

#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGINtypedef NS_ENUM(NSUInteger, IconButtonStyle) {IconButtonStyleTop, // image在上,label在下IconButtonStyleLeft, // image在左,label在右IconButtonStyleBottom, // image在下,label在上IconButtonStyleRight // image在右,label在左
};@interface IconButton : UIButton@property (nonatomic, assign) IconButtonStyle style;@endNS_ASSUME_NONNULL_END

2.2 IconButton.m

#import "IconButton.h"#define SPACE   5@implementation IconButton// 重写layoutSubviews方法,手动设置按钮子控件的位置
- (void)layoutSubviews {[super layoutSubviews];CGFloat buttonWith = self.frame.size.width;CGFloat buttonHeight = self.frame.size.height;CGFloat imageWith = self.imageView.frame.size.width;CGFloat imageHeight = self.imageView.frame.size.height;CGFloat labelWidth = self.titleLabel.frame.size.width;CGFloat labelHeight = self.titleLabel.frame.size.height;CGFloat totalWidth = imageWith+labelWidth+SPACE;if (self.style == IconButtonStyleLeft) {self.imageView.frame = CGRectMake((buttonWith-totalWidth)/2,self.imageView.frame.origin.y,imageWith,imageHeight);self.titleLabel.frame = CGRectMake(self.imageView.frame.origin.x+imageWith+5,self.titleLabel.frame.origin.y,labelWidth,labelHeight);} else if (self.style == IconButtonStyleRight) {self.titleLabel.frame = CGRectMake((buttonWith-totalWidth)/2,self.titleLabel.frame.origin.y,labelWidth,labelHeight);self.imageView.frame = CGRectMake(self.titleLabel.frame.origin.x+labelWidth+SPACE,self.imageView.frame.origin.y,imageWith,imageHeight);} else if (self.style == IconButtonStyleTop) {self.imageView.frame = CGRectMake((buttonWith-imageWith)/2,(buttonHeight-imageHeight-labelHeight-SPACE)/2,imageWith,imageHeight);self.titleLabel.frame = CGRectMake((buttonWith-labelWidth)/2,(buttonHeight-imageHeight-labelHeight-SPACE)/2+imageHeight+SPACE,labelWidth,labelHeight);} else {self.titleLabel.frame = CGRectMake((buttonWith-labelWidth)/2,(buttonHeight-imageHeight-labelHeight-5)/2,labelWidth,labelHeight);self.imageView.frame = CGRectMake((buttonWith-imageWith)/2,(buttonHeight-imageHeight-labelHeight-5)/2+labelHeight+5,imageWith,imageHeight);}
}@end

2.3 使用

#import "IconButtonController.h"
#import "IconButton.h"@interface IconButtonController ()@end@implementation IconButtonController- (void)viewDidLoad {[super viewDidLoad];self.title = @"自定义按钮";IconButton *btn1 = [[IconButton alloc] initWithFrame:CGRectMake(30, 30, SCREEN_WIDTH-60, 100)];[btn1 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn1 setTitle:@"保存完成" forState:UIControlStateNormal];[btn1.titleLabel setTextColor:[UIColor whiteColor]];[btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn1.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn1 setBackgroundColor:[UIColor orangeColor]];btn1.layer.cornerRadius = 5;btn1.layer.masksToBounds = YES;[self.view addSubview:btn1];IconButton *btn2 = [[IconButton alloc] initWithFrame:CGRectMake(30, 160, SCREEN_WIDTH-60, 100)];[btn2 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn2 setTitle:@"保存完成" forState:UIControlStateNormal];[btn2.titleLabel setTextColor:[UIColor whiteColor]];[btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn2.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn2 setBackgroundColor:[UIColor orangeColor]];btn2.layer.cornerRadius = 5;btn2.layer.masksToBounds = YES;[self.view addSubview:btn2];IconButton *btn3 = [[IconButton alloc] initWithFrame:CGRectMake(30, 290, SCREEN_WIDTH-60, 100)];[btn3 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn3 setTitle:@"保存完成" forState:UIControlStateNormal];[btn3.titleLabel setTextColor:[UIColor whiteColor]];[btn3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn3.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn3 setBackgroundColor:[UIColor orangeColor]];btn3.layer.cornerRadius = 5;btn3.layer.masksToBounds = YES;[self.view addSubview:btn3];IconButton *btn4 = [[IconButton alloc] initWithFrame:CGRectMake(30, 420, SCREEN_WIDTH-60, 100)];[btn4 setImage:[UIImage imageNamed:@"user_default_blue"] forState:UIControlStateNormal];[btn4 setTitle:@"保存完成" forState:UIControlStateNormal];[btn4.titleLabel setTextColor:[UIColor whiteColor]];[btn4 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];[btn4.titleLabel setFont:[UIFont systemFontOfSize:16]];[btn4 setBackgroundColor:[UIColor orangeColor]];btn4.layer.cornerRadius = 5;btn4.layer.masksToBounds = YES;[self.view addSubview:btn4];btn1.style = IconButtonStyleLeft;btn2.style = IconButtonStyleRight;btn3.style = IconButtonStyleTop;btn4.style = IconButtonStyleBottom;
}@end

2.4 效果图

在这里插入图片描述

三、采用继承UIControl,重写按钮控件方式实现

新建一个类:HSImageBtn,继承于:UIControl,添加如下代码:

3.1 HSImageBtn.h

#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGINtypedef NS_ENUM(NSUInteger, HSImageBtnStyle) {HSImageBtnStyleTop, // image在上,label在下HSImageBtnStyleLeft, // image在左,label在右HSImageBtnStyleBottom, // image在下,label在上HSImageBtnStyleRight // image在右,label在左
};@interface HSImageBtn : UIControl@property(nonatomic, copy)NSString *title;
@property(nonatomic, copy)UIColor *titleColor;
@property(nonatomic, copy)UIFont *font;
@property(nonatomic, copy)UIImage *image;@property (nonatomic, assign) HSImageBtnStyle style;@endNS_ASSUME_NONNULL_END

3.2 HSImageBtn.m

#import "HSImageBtn.h"@interface HSImageBtn ()@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *icon;@end@implementation HSImageBtn- (instancetype)initWithFrame:(CGRect)frame
{self = [super initWithFrame:frame];if (self) {[self defindContentUI];}return self;
}- (void)defindContentUI
{self.icon = [[UIImageView alloc] initWithFrame:CGRectZero];[self addSubview:self.icon];self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];self.titleLabel.textAlignment = NSTextAlignmentLeft;[self addSubview:self.titleLabel];
}- (void)setStyle:(HSImageBtnStyle)style
{_style = style;if (self.style == HSImageBtnStyleLeft) {[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {make.left.equalTo(self).offset(5);make.centerY.equalTo(self);make.width.mas_equalTo(25);make.height.mas_equalTo(25);}];[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {make.left.equalTo(self.icon.mas_right).offset(5);make.centerY.equalTo(self);make.right.equalTo(self).offset(-5);}];} else if (self.style == HSImageBtnStyleRight) {[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {make.left.equalTo(self).offset(5);make.centerY.equalTo(self);}];[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {make.left.equalTo(self.titleLabel.mas_right).offset(5);make.centerY.equalTo(self);make.width.mas_equalTo(25);make.height.mas_equalTo(25);}];} else if (self.style == HSImageBtnStyleTop) {[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(self).offset(5);make.centerX.equalTo(self);make.width.mas_equalTo(25);make.height.mas_equalTo(25);}];[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(self.icon.mas_bottom).offset(5);make.centerX.equalTo(self);}];} else {[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(self).offset(5);make.centerX.equalTo(self);}];[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(self.titleLabel.mas_bottom).offset(5);make.centerX.equalTo(self);make.width.mas_equalTo(25);make.height.mas_equalTo(25);}];}
}#pragma mark - Setter- (void)setTitle:(NSString *)title{_title = title;self.titleLabel.text = title;
}-(void)setTitleColor:(UIColor *)titleColor{_titleColor = titleColor;self.titleLabel.textColor = titleColor;
}- (void)setFont:(UIFont *)font{_font = font;self.titleLabel.font = font;
}- (void)setImage:(UIImage *)image {_image = image;self.icon.image = image;
}@end

3.3 使用

#import "IconButton3Controller.h"
#import "HSImageBtn.h"@interface IconButton3Controller ()@end@implementation IconButton3Controller- (void)viewDidLoad {[super viewDidLoad];self.title = @"自定义按钮";HSImageBtn *btn1 = [[HSImageBtn alloc] initWithFrame:CGRectZero];btn1.backgroundColor = [UIColor orangeColor];btn1.title = @"保存";btn1.titleColor = [UIColor whiteColor];btn1.font = [UIFont systemFontOfSize:16];btn1.image = [UIImage imageNamed:@"user_default_blue"];[btn1 addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn1];HSImageBtn *btn2 = [[HSImageBtn alloc] initWithFrame:CGRectZero];btn2.backgroundColor = [UIColor orangeColor];btn2.title = @"保存";btn2.titleColor = [UIColor whiteColor];btn2.font = [UIFont systemFontOfSize:16];btn2.image = [UIImage imageNamed:@"user_default_blue"];[btn2 addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn2];HSImageBtn *btn3 = [[HSImageBtn alloc] initWithFrame:CGRectZero];btn3.backgroundColor = [UIColor orangeColor];btn3.title = @"保存";btn3.titleColor = [UIColor whiteColor];btn3.font = [UIFont systemFontOfSize:16];btn3.image = [UIImage imageNamed:@"user_default_blue"];[btn3 addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn3];HSImageBtn *btn4 = [[HSImageBtn alloc] initWithFrame:CGRectZero];btn4.backgroundColor = [UIColor orangeColor];btn4.title = @"保存";btn4.titleColor = [UIColor whiteColor];btn4.font = [UIFont systemFontOfSize:16];btn4.image = [UIImage imageNamed:@"user_default_blue"];[btn4 addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn4];btn1.style = HSImageBtnStyleLeft;btn2.style = HSImageBtnStyleRight;btn3.style = HSImageBtnStyleTop;btn4.style = HSImageBtnStyleBottom;[btn1 mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(self.view).offset(20);make.centerX.equalTo(self.view);make.width.mas_equalTo(80);make.height.mas_equalTo(60);}];[btn2 mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(btn1.mas_bottom).offset(20);make.centerX.equalTo(self.view);make.width.mas_equalTo(80);make.height.mas_equalTo(60);}];[btn3 mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(btn2.mas_bottom).offset(20);make.centerX.equalTo(self.view);make.width.mas_equalTo(80);make.height.mas_equalTo(60);}];[btn4 mas_makeConstraints:^(MASConstraintMaker *make) {make.top.equalTo(btn3.mas_bottom).offset(20);make.centerX.equalTo(self.view);make.width.mas_equalTo(80);make.height.mas_equalTo(60);}];
}- (void)buttonClick
{NSLog(@"按钮点击了...");
}@end

3.4 效果图

在这里插入图片描述
Demo下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_39151.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

装在笔记本里的私有云环境:K8s 集群准备

本篇是系列中的第六篇内容&#xff0c;继续聊聊如何把一个简化过的私有云环境部署在笔记本里&#xff0c;以满足低成本、低功耗、低延时的实验环境。 在前几篇内容中&#xff0c;我们聊过了&#xff1a;虚拟化、监控、基础的存储、持续集成等内容&#xff0c;接下来的内容中&a…

Javaweb的AJAX及Axios框架使用(封装AJAX)

概念: AJAX(Asynchronous JavaScript And XML):异步的JS和XML。 作用: 与服务器进行数据交换 :通过AJAX可以给服务器发送请求。使用AJAX和服务器进行通信&#xff0c;就可以使用HTMLAJAX来替换JSP页面。异步交互 :可以在不重新加载整个页面的情况下&#xff0c;与服务器交互…

自己搭建网站【搭建网站】

现在搭建网站也不只是企业公司商家的专利&#xff0c;很多个人用户都想拥有属于自己的一个网站。那么怎么自己搭建网站呢&#xff1f;下面给大家简单说说。 一、申请域名 域名是访问网站的地址&#xff0c;这是必须要有的&#xff0c;可以在域名服务商网站上申请。申请域名需要…

jupyter中配置多种虚拟环境

Microsoft Windows [版本 10.0.19044.2251] © Microsoft Corporation。保留所有权利。 C:\Users\ThinkStation>conda activate pytorch(pytorch) C:\Users\ThinkStation>conda install ipykernelCollecting package metadata (current_repodata.json): done Solvin…

机械硬盘HDD

硬盘&#xff08;英语&#xff1a;Hard Disk Drive&#xff0c;缩写&#xff1a;HDD&#xff0c;有时为了与固态硬盘相区分称“机械硬盘”或“传统硬盘”&#xff09;是电脑上使用坚硬的旋转盘片为基础的非易失性存储器&#xff0c;它在平整的磁性表面存储和检索数字数据&#…

【强化学习论文合集 | 2020年合集】一. ICML-2020 强化学习论文

强化学习(Reinforcement Learning, RL),又称再励学习、评价学习或增强学习,是机器学习的范式和方法论之一,用于描述和解决智能体(agent)在与环境的交互过程中通过学习策略以达成回报最大化或实现特定目标的问题。 本专栏整理了近几年国际顶级会议中,涉及强化学习(Rein…

SpringCloud_第1章_入门到精通()

SpringCloud_第1章_入门到精通 文章目录SpringCloud_第1章_入门到精通1.认识微服务1.0.学习目标1.1.单体架构1.2.分布式架构1.3.微服务1.4.SpringCloud1.5.总结2.服务拆分和远程调用2.1.服务拆分原则2.2.服务拆分示例2.2.1.导入Sql语句2.2.2.导入demo工程2.3.实现远程调用案例2…

间隔不到一年开两店,温州鸿雁全屋智能经销商透露了他的生意经

作者 | 牧之 编辑 | 小沐 出品 | 智哪儿 zhinaer.cn编者按&#xff1a;间隔不到一年&#xff0c;连续开设了两家全屋智能体验店。这是发生在温州的渠道商故事。本期专访&#xff0c;「智哪儿」对话浙江林上智能科技有限公司总经理朱飞隆先生。他为何做智能家居&#xff1f;为何…

History、Location

History、Location 学习路线&#xff1a;JavaScript_BOM->Window对象->confirm()、setInterval()、setTimeout()->History、Location->闪烁的灯泡 History History 对象是 JavaScript 对历史记录进行封装的对象。 History 对象的获取 使用 window.history获取&a…

计算机四级网络-网络技术-第六章 网络管理与网络安全

6.1 网络管理技术 CMIP 采用委托监控机制。 CMIP协议是由IS0组织制定的一种管理协议。管理进程根据事件发生时对网络服务影响的大小来划分事件的严重等级&#xff0c;然后再产生相应的故障处理方案。CMIP的所有功能都要映射到应用层的相关协议上实现。操作和事件报告是通过远…

2023 年 10 大 Web 开发趋势

公司的在线形象是最重要的。您使用的平台越多&#xff0c;您就会变得越成功&#xff01;拥有在线形象的困难部分是脱颖而出。如果你没有有趣的东西可以提供&#xff0c;你会迷失在人群中。 除了网站具有的基本功能外&#xff0c;您还需要拥有更多功能才能使您的网站具有可持续…

在RVIZ中显示深度数据

文章目录深入 RVIZ景深图深度云点云置信度视差C中的深度订阅参考深入 RVIZ 在本教程中&#xff0c;您将详细了解如何配置您自己的 RVIZ 会话以仅查看您需要的深度数据。 深度信息可以通过许多不同的方式可视化&#xff1a;2D 深度图像、3D 点云、3D 注册深度云和置信度图像等…

剑指Offer专项突破版(76)—— 数组中的第 k 大的数字

题目 剑指 Offer II 076. 数组中的第 k 大的数字 思路 假设有个划分函数divide&#xff1a; divide&#xff1a;将num在[l,r]范围内&#xff0c;按照nums[l]进行划分&#xff0c;返回一个数组range&#xff0c;划分为&#xff1a; 所有小于nums[l]的数&#xff1a;移动到nu…

[NCTF2019]SQLi

进来就有个弹窗 甚至给了sql语句 sqlquery : select * from users where username and passwd 先扫一下目录&#xff0c;发现有个robots.txt 提示有个hint.txt $black_list "/limit|by|substr|mid|,|admin|benchmark|like|or|char|union|substring|select|greatest|%00…

Kotlin高仿微信-第18篇-单聊-删除单条信息

Kotlin高仿微信-项目实践58篇详细讲解了各个功能点&#xff0c;包括&#xff1a;注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。 Kotlin高仿…

Qt编写视频监控系统67-录像计划(支持64通道7*24录像设置)

一、前言 录像计划这个功能一直挂了很久&#xff0c;之前做的也都有保存视频文件功能&#xff0c;其中还分了三大种&#xff0c;第一种是手动开启和停止录像&#xff1b;第二种是按照指定时长比如10s保存文件&#xff1b;第三种是定时30分钟一个文件一直保存。这三种功能直接写…

opengl,opengl es,egl,glfw,glew

OpenGL ES之GLFW窗口搭建 - Plato - 博客园概述 本章节主要总结如何使用GLFW来创建Opengl窗口。主要包括如下内容&#xff1a; OpenGl窗口创建介绍 GLFW Window版编译介绍 GLFW简单工程源码介绍 OpenGL窗口创建介绍 能用于Ohttps://www.cnblogs.com/feng-sc/p/5093262.htmlOp…

2022-11-30 Github Forking 工作流模式

Forking 工作流 fork 操作是在个人远程仓库新建一份目标远程仓库的副本&#xff0c;流程如下&#xff1a; 比如在 GitHub 上操作时&#xff0c;在项目的主页点击 fork 按钮&#xff08;页面右上角&#xff09;&#xff0c;即可拷贝该目标远程仓库。 假设开发者 A 拥有一个远程仓…

电脑怎么提取图片中的文字?

图片记录着我们生活的点点滴滴&#xff0c;比如各种办公截图、查快递单号、布置的课堂作业等等&#xff0c;都离不开这种便捷的方法。而我们有时难免需要从图片中提取想要的文字&#xff0c;总不能就靠打字打到手软吧&#xff0c;那么电脑怎么提取图片中的文字呢?有需要的朋友…

终于有阿里p8进行了大汇总(Redis+JVM+MySQL+Spring)还有面试题解全在这里了!

Redis特性 Redis是一直基于键值对的NoSQL数据库&#xff1b; Redis支持5种主要数据结构&#xff1a;string、hash、list、set、zset以及bitmaps、hyperLoglog、GEO等特化的数据结构&#xff1b; Redis是内存数据库&#xff0c;因此它有足够好的读写性能&#xff1b; Redis支持…