如何自定义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 imageThe 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
最满意答案
您的问题的基本答案是是的,您可以使用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 onuse_frameworks!
flag in yourPodfile
:
Let's imagine that you want use Objective-C pod with nameCoolObjectiveCLib
.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 ...
-
如何在Objective-C项目中导入和使用Swift Pod Framework(How to import and use Swift Pod Framework in Objective-C Project)[2022-12-18]
我认为你必须将swift类声明为public,否则它被视为一个内部类,只能在同一个模块中被看到,这可能是为什么将它添加到与文件一样工作的同一个项目中的原因,但是一个框架没有。 我发生的其他事情是,框架可能需要在类声明之前添加@objc,以便在Objective-c类中可以看到它。 同时阅读Apple的目标c和swift之间的Mix和Match指南,它指出当您导入外部框架时,您需要确保将要导入的框架的“定义模块”构建设置设置为“是”。 你检查过这些选项吗? I think you have to declar ... -
如何在Swift项目中使用Objective-C Cocoapods?(How to use Objective-C CocoaPods in a Swift Project)[2022-09-08]
您的问题的基本答案是是的,您可以使用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 ...
-
Firebase Cocoapods - 错误消息;(Firebase Cocoapods - Error message; Could not build Objective-C module 'Firebase)[2024-01-09]
假设你已经通过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 ...
-
在Swift中使用CocoaPods(Using CocoaPods with Swift)[2022-03-31]
您需要将模块导入源文件 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 ...