简体   繁体   English

如何在通知内容扩展中为我的自定义视图应用自定义字体/颜色和半透明背景?

[英]How to apply custom font/color and semi-transparent background for my custom view in notification content extension?

I implemented Notification content extension for customizing my push notification alert. 我实现了Notification内容扩展,用于自定义推送通知警报。 I got the alert like the following image. 我收到如下图所示的警报。

在此处输入图片说明

But I would like to apply following things to my custom view 但我想将以下内容应用于我的自定义视图

1: How to make blurred/semi-transparent background for custom view ? 1:如何使自定义视图的背景模糊/半透明?

2: How to apply custom fonts (already used in my application )for different labels in this custom view ? 2:如何在此自定义视图中为不同标签应用自定义字体(已在我的应用程序中使用)?

3: How to apply different colors for views from my custom color class ? 3:如何为自定义颜色类的视图应用不同的颜色?

I already added custom font to my application target.But I cannot access these fonts to my custom view used in extension. 我已经在我的应用程序目标中添加了自定义字体。但是我无法在扩展中使用的自定义视图中访问这些字体。 Please help me how to solve these issues? 请帮我如何解决这些问题?

  1. I'm not sure what you mean by blurred? 我不确定您所说的模糊是什么意思? Do you want to blur the entire background of the notification? 您是否要模糊通知的整个背景? That is not possible I'm afraid. 恐怕这是不可能的。

  2. Here is a good article explaining the steps you need to take to include a custom font into multiple targets (your main app being one target, and your extension being another). 是一篇很好的文章,解释了将自定义字体包含到多个目标中时需要采取的步骤(您的主应用程序是一个目标,而扩展名是另一个目标)。 My guess is that you have not included it in your extensions .plist as well. 我的猜测是,您也没有将其包含在扩展名.plist中。

  3. The same is also true for your custom color class. 您的自定义颜色类别也是如此。 However, if your custom color class is dependent on other classes, they will need to be added to the extension target as well, which can be a deep rabbit hole to go down. 但是,如果您的自定义颜色类别依赖于其他类别,则也需要将它们添加到扩展目标中,这可能是一个深坑。 If that's the case, either try to get rid of some dependencies or in worst case, just replicate the custom color class in your extension. 如果是这种情况,请尝试摆脱某些依赖性,或者在最坏的情况下,只需在扩展名中复制自定义颜色类。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM