首页 \ 问答 \ 如何自定义ActionBar上的后退按钮(How to customize the back button on ActionBar)

如何自定义ActionBar上的后退按钮(How to customize the back button on ActionBar)

我已经能够使用以下建议自定义动作栏的背景,标志图像和文字颜色:
Android:如何将ActionBar“Home”图标更改为应用程序图标以外的其他图标?
ActionBar文字颜色
ActionBar背景图片

我想要自定义的最后一件是后退按钮图像。 默认为灰色,我希望它是白色的。 改变颜色,指定可绘制或简单地使其透明(并将V形纹理添加到我的自定义徽标图像)将起作用。 我该怎么办?


I have been able to customize the action bar's background, logo image and text color using suggestions from these:
Android: How to change the ActionBar "Home" Icon to be something other than the app icon?
ActionBar text color
ActionBar background image

The last piece I want to customize is the back button image. It's grey by default and I would like it to be white. Either changing the color, specifying a drawable or simply making it transparent (and adding the chevron to my customized logo image) would work. How do I go about that?


原文:https://stackoverflow.com/questions/9252354
更新时间:2022-03-07 14:03

最满意答案

您的问题的基本答案是是的,您可以使用CocoaPods构建的Objective-C代码。

更重要的问题是“如何使用这样的库?”
这个问题的答案取决于use_frameworks! 您的Podfile标志:
让我们想象你想要使用名为CoolObjectiveCLib Objective-C pod。

如果您的pod文件使用use_frameworks! 旗:

// Podfile
use_frameworks!
pod 'CoolObjectiveCLib'

那么你不需要添加任何桥头文件。
您需要的一切都是Swift源文件中的导入框架:

// MyClass.swift
import CoolObjectiveCLib

现在您可以使用lib中显示的所有类。

如果您的pod文件不使用use_frameworks! 旗:

// Podfile
pod 'CoolObjectiveCLib'

那么你需要创建桥接头文件并导入所有必要的Objective-C头文件:

// MyApp-Bridging-Header
#import "CoolObjectiveCLib.h"

现在您可以使用导入标头中定义的所有类。


Basic answer to your question is Yes, you can use objective-c code built with CocoaPods.

More important question is "How to use such libs?"
Answer on this question depends on use_frameworks! flag in your Podfile:
Let's imagine that you want use Objective-C pod with name CoolObjectiveCLib.

If your pod file uses use_frameworks! flag:

// Podfile
use_frameworks!
pod 'CoolObjectiveCLib'

Then you don't need add any bridge header files.
Everything that you need is import framework in Swift source file:

// MyClass.swift
import CoolObjectiveCLib

Now you can use all classes that are presented in lib.

If your pod file doesn't use use_frameworks! flag:

// Podfile
pod 'CoolObjectiveCLib'

Then you need create bridging header file and import there all necessary Objective-C headers:

// MyApp-Bridging-Header
#import "CoolObjectiveCLib.h"

Now you can use all classes that are defined in imported headers.

相关问答

更多
  • 如果你看看你的主要目标版本设置,你会看到有很多目录列在“标题搜索路径”设置中。 您可能需要在测试目标下复制这些值,或者您可以尝试修改您的Podfile以包含主目标和测试目标,然后重新运行install : platform :ios, '7.0' link_with 'mainapp', 'mainappTests' ... 还要注意可能需要的并且与CocoaPods无关的任何其他头文件路径。 不要忘记,你的班级在任何你想要进行单元测试的地方都应该有公开的方法。 希望这可以帮助。 If you take ...
  • 我认为你必须将swift类声明为public,否则它被视为一个内部类,只能在同一个模块中被看到,这可能是为什么将它添加到与文件一样工作的同一个项目中的原因,但是一个框架没有。 我发生的其他事情是,框架可能需要在类声明之前添加@objc,以便在Objective-c类中可以看到它。 同时阅读Apple的目标c和swift之间的Mix和Match指南,它指出当您导入外部框架时,您需要确保将要导入的框架的“定义模块”构建设置设置为“是”。 你检查过这些选项吗? I think you have to declar ...
  • 您的问题的基本答案是是的,您可以使用CocoaPods构建的Objective-C代码。 更重要的问题是“如何使用这样的库?” 这个问题的答案取决于use_frameworks! 您的Podfile标志: 让我们想象你想要使用名为CoolObjectiveCLib Objective-C pod。 如果您的pod文件使用use_frameworks! 旗: // Podfile use_frameworks! pod 'CoolObjectiveCLib' 那么你不需要添加任何桥头文件。 您需要的一切都是 ...
  • Cocoapods 0.36及以上介绍use_frameworks! 指令,这意味着在Swift中导入Objective-C pod并不需要桥接头。 请在下面找到一个使用MBProgressHUD和Alamofire的完整示例: Podfile source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.3' use_frameworks! pod 'Alamofire', '>= 1.2.2' # Swift pod pod 'MB ...
  • 假设你已经通过CocoaPods正确安装了FireBase。 尝试以下步骤 第1步 - 关闭Xcode 第2步 - 清除您的派生数据。 你可以在这里找到你的派生数据 ~/Library/Developer/Xcode/DerivedData 第3步 - 打开你的.xcworkspace 第4步 - 清理项目(⌘+ Shift + K) 第5步 - 构建您的项目(⌘+ B) 希望这可以帮助。 Assuming that you have installed FireBase properly via Coc ...
  • 使用CocoaPod的标准方式是遵循第一个链接的说明。 请参阅创建文本检测器部分。 如果你真的想把框架拉出CocoaPod。 从podspec中的source属性加载链接以获取包含pod内容的tar.gz文件。 The standard way of working with a CocoaPod is following the instructions from your first link. See the Creating the text detector section. If you rea ...
  • 使用此功能并执行pod install ,您无需删除pod'Charts' target 'chart4' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks use_frameworks! # Pods for chart4 pod 'Charts' pod 'MaterialComponents' Use this and do po ...
  • 原来我只是缺少类/函数声明中的public修饰符: public class SomeClass : NSObject Turns out I was just missing the public modifier on the class/function declarations: public class SomeClass : NSObject
  • 它们很有用,直到你得到一个与另一个pod冲突的pod ... 如果你添加了你需要的所有pod,它们的工作非常棒! 我过去曾几次遇到过他们的问题 如果你编辑podfile以便它只使用你知道正在工作的每个pod的特定版本,那么即使他们更新了他们的框架它也永远不会破坏 这样做可以通过以下方式完成: pod 'AFNetworking', '2.0' 例如,这只会使用AFNetworking的v2.0。 如果在某些时候你确实发现他们搞砸了你的项目,那么移除pod并手动添加所有框架并不是什么大问题 They are ...
  • 您需要将模块导入源文件 import DateTools 此外,默认情况下,CocoaPods构建静态库 - 使用您需要配置桥接头的那些库。 更简单的方法是通过在Podfile指定(并运行pod install )来使其构建动态框架: use_frameworks! pod 'DateTools' You need to import module into your source file import DateTools Also, by default is CocoaPods buildin ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)