navigationItem左右按钮偏移的问题(left,right)

iOS小技能:调整导航条BarButtonItem与屏幕边界/titleView 的间距及常见问题的解决方案(BarButtonItem 隐藏失效) 与屏幕边界 或者与titleView 的间距 只要分别调整rightBarButtonItems 数组元素的顺序。主要利用UIBarButtonItem 的UIBarButtonSystemItemFixedSpace 系统控件 UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] 阅读详情

- (void)addBarButtonItemWithImageNameleftCustom:(NSString *)imageName selector:(SEL)selector close:(SEL)closeBtn

{

    UIButton *barButton = [UIButton buttonWithType:UIButtonTypeCustom];

    [barButton setFrame:CGRectMake(0, 0, 30, 30)];

    [barButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];

    [barButton addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:barButton];

    

    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]

                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                       target:nil action:nil];

    negativeSpacer.width = -13;

    

    UIButton *close = [UIButton buttonWithType:UIButtonTypeCustom];

    [close setFrame:CGRectMake(0, 0, 30, 30)];

    [close setTitle:@"关闭" forState:UIControlStateNormal];

    close.titleLabel.font = [UIFont boldSystemFontOfSize:14];

    [close setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    [close addTarget:self action:closeBtn forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *closeItem = [[UIBarButtonItem alloc] initWithCustomView:close];


    

    self.navigationItem.leftBarButtonItems = @[negativeSpacer,item,closeItem];

    

}

解决iOS7 UIBarButtonItem右移错位问题. 解决iOS7 UIBarButtonItem右移错位问题 立即下载

相关推荐

【ROS2】MOMO的鱼香ROS2(三)ROS2入门篇——ROS2第一个节点

【ROS2】MOMO的鱼香ROS2(三)ROS2入门篇——ROS2第一个节点

qq_44703886的博客 3614

IOS中设置navigationItem的leftBarButtonItem或rightBarButtonItem与边界距离

我们发现,在设置navigationItem的leftBarButtonItem或rightBarButtonItem时,用CustomView初始化UIBarButtonItem,不论怎么设置CustomView的frame,添加到导航条上之后总是和屏幕边界有一定的间距(5pix),如何自由调整这个间距呢? 初始化一个用于控制间距的UIBarButtonItem实例negativeSpacer,并设置negativeSpacer的width属性的值,设为-5的时候,正好可以使按钮与屏幕边界值为0,以rig

兵仔贾---的专栏 7785

如何编译RustDesk(Unbuntu 和Android版本)

备注:官方文档上,一边都是基于sciter,这个在后面已经不建议使用了,但是依然可以编译刚开始的时候看官方的文档,涉及的东西比较多,也搞的一头雾水,通过B站上一个视频,可以通过CI/CD来编译,以及act本地试试(最终放弃,大概需要下载大几十G的容器下来)。最终总算明确了方向,可以用自动化流水线来编译。直接看CI/CD的脚本文件文件在.github/workflows目录下,重点研究 bridge.yml 和flutter-build.yml 这两个文件。

lvronglee的专栏 2547

self.navigationItem.leftBarButtonItem 的大小

从一个界面跳到下一个界面,这个功能不难实现,But:根据UI给的设计图,下一个界面需要更改返回按钮的样式只有一个< 这样的返回按钮,UI这样设计的话,系统自带的返回就不能用了,在开发过程中作为一个有经验的开发者,都会自己去自定义一些东西,当然了,有相应的第三方类库就更好了,但各种各样的问题也会出现,由于代码不是自己写的,所以修改起来也比较头疼 言归正传: 问题描述: 最近一个项目中运用...

SJN的博客 1605

[小梅哥FPGA] 如何通过动态重配置实现FPGA时钟的实时频率/相位/占空比调整?

PLL和MMCM是实际存在的硬件电路,用以对输入时钟的负面变化,如抖动、频率变化、相位偏移、占空比失真等进行处理。基于该表,用户在初始化Clk_Wiz后,只需要计算好所需的频率、相位、占空比对应的设置值,使用Xil_Out32函数配置对应寄存器即可。通过上述步骤,在平时的开发调试过程中,亦或是一些对于时钟可能有着实时性要求的设计(如数据采集、图像处理)里,我们便可以在无需重新修改设计的前提下,通过AXI4总线来完成对时钟频率、相位的调控,从而达到缩短设计周期以及让设计适应更多场景的目的。

zgmxs的专栏 2493

微信小程序测试号开发后上传按钮灰色?三步快速切换正式AppID

本文详细解析了微信小程序测试号开发后上传按钮灰色的原因,并提供了三步快速切换正式AppID的解决方案。通过注册正式小程序账号、修改项目配置和重新编译上传,开发者可以轻松解决上传按钮不可用的问题,确保小程序顺利上线。

weixin_29291185的博客 1575

调整导航条上leftBarButtonItem和rightBarButtonItem与屏幕边界的间距

转载自:http://blog.youkuaiyun.com/numbbuaa/article/details/8594638 我们发现,在设置navigationItem的leftBarButtonItem或rightBarButtonItem时,用CustomView初始化UIBarButtonItem,不论怎么设置CustomView的frame,添加到导航条上之后总是和屏幕边界有一定的间距(

沸腾的泪水的专栏 4273

基于Matlab的自动泊车系统开发:利用模糊控制实现智能停车解决方案的详细教程

Matlab是一种广泛应用于科学计算、工程建模与仿真的编程语言,其强大的工具箱和简洁的编程语法,使其成为开发自动泊车系统的理想选择。在开始编写代码之前,我们需要搭建Matlab的工作环境,并熟悉相关的工具箱,如Fuzzy Logic Toolbox,用于实现模糊控制。首先,确保你已经安装了Matlab软件,并加载了必要的工具箱。接下来,我们将逐步讲解如何在Matlab中实现自动泊车系统。

qq_38334677的博客 663

调整leftBarButtonItem 的位置

如果不知道leftBarButtonItem的值,那么默认push后,显示的是Back按钮,如   如果设置了leftBarButtonItem的值,如 UIBarButtonItem *leftButon = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"BackButton"] style:UIBa

newadice的专栏 1万+

YOLOv11 改进 - 注意力机制 | Deformable-LKA 可变形大核注意力:自适应采样网格优化特征捕捉,提升不规则目标感知

本文介绍了可变形大核注意力(D-LKA Attention)及其在YOLOv11中的结合。D-LKA Attention是一种简化的注意力机制,采用大卷积核利用体积上下文信息,通过可变形卷积灵活调整采样网格,适应多样数据模式。它有2D和3D版本,3D版本在跨深度数据理解上表现出色,共同构成了D-LKA Net架构。我们将D-LKA Attention集成进YOLOv11,在模型的检测头部分引入deformable_LKA_Attention模块。实验表明,该方法在分割任务上表现优于现有方法,提升了模型的检测

魔改工程师的博客 1170

SAP-ABAP:SAP IDOC 全面学习指南

SAP-ABAP:SAP IDOC 全面学习指南

baidu_35680696的博客 1616

iOS: share项目难点梳理

有一个需要注意的点,就是我们把滚动视图的tableView的第一个cell中, 在调试的过程中, 会发现当我们在滑动tableView的时候, 第一个cell中的定时器会暂停, 然后当停止滑动的时候, 视图会连续翻页,这里涉及到了RootLoop 与 Mode 的知识, 笔者还不太了解, 解决方法就是在创建定时器的时候加上下面这段代码。定义协议, 在列表页要实现协议方法。

for_ever_love__的博客 180

EDKII环境配置完整版

参考博客【EDK2 UDK2018的环境搭建】:https://blog.youkuaiyun.com/qq_39155263/article/details/82965744下载EDK2 1.直接从https://github.com/tianocore/edk2/ 网站下载.zip压缩文件 2.运用svn 从http://svn.code.sf.net/p/edk2/code/trunk/edk2edk2下载 3.安装Visual Studio2017 安装其他Tool 1.IASL 从https..

tianpu2320959696的博客 1851

UIkit基本框架

本文包含了IOS界面开发中的常用控件以及其他相关知识,持续更新中

2301_77900444的博客 405

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

leftBarButtonItem设置左边距,rightBarButtonItem设置右边距

UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 44)];     [backButton addTarget:self action:@selector(navigationBackButtonClicked) forControlEvents:UIControlEventTouc

dcjxrk的博客 7787

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

iOS导航BarButtonItem文字或者图片与屏幕边界的间隔调整方法

在设置navigationItem的leftBarButtonItem或rightBarButtonItem时, 用CustomView初始化UIBarButtonItem,不论怎么设置CustomView的frame, 添加到导航条上之后总是和屏幕边界有一定的间距(5pix), 如何自由调整这个间距呢? 下面w

标哥 2万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

navigation left item or right item

//加左边按钮     func setupLeftBarButtonItem(){                  let btn1 = UIButton.init(frame: CGRectMake(0, 0, 50, 30))         btn1.setTitle("完成", forState: UIControlState.Normal)

kangli的专栏 403

关于NavigationItem.rightBarButtonItem设置

第一种: UIImage *searchimage=[UIImage imageNamed:@"search.png"];     UIBarButtonItem *barbtn=[[UIBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStyleDone target:self action:@selector(sea

NightWish 5万+

NavigationItem.rightBarButtonItem设置

     startBtn = [[UIButton alloc]initWithFrame:CGRectMake(0,0,40,40)]; [startBtn setImage:[UIImage imageNamed:@"title_button_收藏"]forState:UIControlStateNormal]; [startBtn setImage:[UIIma...

jimmychan的博客 1668

给self.navigationItem.rightBarButtonItem设置字体颜色所引发的忧伤

其实一般去自定义一个 UIBarButtonItem 然后都会玩得很 high,很满足,但是孤独一生的我每次都是想法设法不去自定义,实在是 simple,但是毕竟也是好久没有搞iOS了,刚刚,想给 self.navigationItem.rightBarButtonItem 设置一下字体颜色: UIBarButtonItem *rightitem = [[UIBarButtonItem alloc

thanklife的专栏 2222

iOS UI篇 - NavigationItem.rightBarButtonItem设置

第一种:这种设置出来的外观不好控制:UIImage *searchimage=[UIImage imageNamed:@"search.png"]; UIBarButtonItem *barbtn=[[UIBarButtonItem alloc] initWithImage:nil style:UIBarButtonItemStyleDone target:self action:@sele

jeikerxiao 3848

navigationBarItem 位置偏移

最近发现 navigationBar 左右baritem以及中间的titleView都设定完之后,位置不太对,两边的barItem 位置会偏上(我这的左右item都是customView),如下图出现这种情况直接重写viewDidLayoutSubviews 方法就可以了//调整navigationBar上控件的位置 -(void)viewDidLayoutSubviews{ [_locat

Kaiccy的博客 3186

python多种方法实现二分查找 附性能分析

1二分查找原理 2Python实现 3性能分析

weixin_41989712的博客 480

iOS11NavigationItem偏移,iOS11适配问题,iOS11导航栏返回偏移,iOS11BarButtonItem偏移,Xcode9遇见的问题

更新iOS 11之后,用xcode 9运行App,你会发现以下问题: 1、MJ刷新异常 2、tableView的section之间间距变大 3、导航栏返回按钮偏移20像素 下面我逐个讲一下解决办法: 1、MJ刷新异常,上拉加载出现跳动刷新问题: 解决办法:初始化的时候增加以下代码(tableView和collectionView类似)     if (@avail

zhaotao0617的博客 2万+
上一篇: 安装CocoaPods过程和遇到各种坑
下一篇: app应用下的公司名称错误
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值