一文学会iOS画中画浮窗
背景之前有看到有人用画中画实现时分秒的计时,顺手收藏了,一直没来及看。最近使用《每日英语听力》,突然发现它用画中画实现了听力语句的显示,顿时来了兴趣,所以来研究一下是怎么实现的?顺便也研究下画中画时分秒计时的实现——每次遇到某些平台每天固定时间开抢的时候,我都希望iPhone能够显示具体到秒的计时,这样就能知道什么时候开始点击合适,而不是每次都提前一分钟在那里不停的点点点却什么都抢不到。。。 实现画中画一般是用来浮窗播放视频的,那如何让画中画播放自定义的界面而不是视频?下面分为5步具体来看下: 实现画中画功能,需要设置哪些开关,实现哪些方法; 基本的使用系统播放器时,画中画的实现; 自定义播放器时,画中画功能的实现又需要如何设置,有哪些不同; 如何通过画中画实现时分秒计时功能; 《每日英语听力》通过画中画播放英语听力语句时怎么实现的? APP支持画中画功能如何让APP支持画中画功能?首先需要设置App支持BackgroundModes,然后勾选BackgroundModes中的Audio, Airplay, and Picture in Picture。 操作如下: ...
The 'Pods-App' target has transitive dependencies that include static binaries
The ‘Pods-App’ target has transitive dependencies that include static binaries:修改背景最近遇到了两次次这个问题,都是Swift项目Pod添加库开启了use_frameworks!,安装某些OC库时报错;花了好久时间解决,突然想起来之前OC项目安装Swift库也遇到了这个问题,但是之前没有记录,所以这次遇到时没有印象;这次记录下来,分享给大家: 解决方案之前遇到的是OC代码安装ZLPhotoBrowser的Swift库,开启了use_frameworks!,和其他第三方库一起安装时,可以理解为,除了ZLPhotoBrowser是动态库,其他的第三方库默认都使用static_framework或者static_library。 Pod文件末尾添加下面代码: 12345678910111213141516171819use_frameworks!...dynamic_frameworks = ['ZLPhotoBrowser']pre_install do |installer| ...
图片压缩 mac 应用开发
图片压缩 mac 应用开发背景3年前有个项目BatchProssImage,使用 Python 写的批量压缩图片的,最新再次使用时,发现忘记了怎么使用,所以就有了把这个Python 实现的工具,做成一个简单的 mac app 的想法。 过程想法很简单:印象中当时这个工具是使用 tinypng 的 api 压缩的,所以开发一个 mac客户端,调用压缩的接口,导出照片就可以。开始动工。 首先 mac 客户端的 UI 从哪里来?之前有个项目OtoolAnalyse——分析Mach-O文件中无用的类和方法,是借LinkMapUI 来实现的。这里想了想,嗯,还可以用这个方法。打开项目一看,OC 的,还是用 Swift 写一遍吧。 UI 实现想一下大致需要哪些功能, 选择文件 || 目录 选择导出目录 开始压缩 压缩进度显示 噢噢,还有一个,tinypng apikey 输入 再考虑一下,选择导出目录是否必要?之前笔者自己使用其他 APP 选择导出时,打断先有的操作且不说,对于选择困难来说,每次考虑要导出到哪里都是一个问题,要不要新建一个文件夹,还选择同目录会是什么效果等等。 改为 ...
iOS Widget
iOS Widget背景一开始是发现支付宝的 Widget 做的很好看,打算仿作一个,做的过程中才发现,原来 Widget 有这么多好玩的地方。所以,在这里记录分享一下: 你知道如何创建类似于 QQ 同步助手的 Widget 吗? 你知道类似于东方财富的不同组 Widget 效果是怎么实现的吗? 你知道下图中支付宝Widget功能是怎么实现的吗? 或者这么问,对于这几个的概念:supportedFamilies、WidgetBundle以及Configurable Widget是否知晓,如果都知道,那就不需要看本篇文章了。 QQ 同步助手的Widget只显示一个Widget的效果,是设置了 Widget 的supportedFamilies只有systemMedium 样式; 东方财富的多组 Widget,是通过WidgetBundle实现的,可以设置多个Widget,每个 Widget 都可以设置自己的大中小;区分是否使用了 WidgetBundle,可以通过滑动时,Widg...
《24点》APP——提示功能的实现
更新:《24点》APP——提示功能实现背景商店里所有24点 APP 的一个付费功能是提示的获取,会通过限制提示次数,超出次数后观看广告或者购买来解锁额外次数。比如: 这里就来分享一下,类似24点的提示功能是怎么实现的,其实现步骤如下: 步骤一:判断结果能不能等于24; 步骤二:如果能等于24,显示出能得到24的表达式。 下面详细记录一下实现的过程: 解法原理步骤一,判断能不能等于24有[a, b, c, d] 四个数字,任取两个数字,通过遍历运算符得到运算结果 e,然后把运算结果和剩余的数字放入新的数组中,重复上面的计算过程,直到数组中有一个元素为止;最后判断数组中唯一的数字是否等于24即可。 这里需要注意几点,一是遍历运算符的时候,加和乘符合交换律,所以不需要重复计算;二是除法会有小数,所以最终判断是否等于24的时候,需要通过设置误差范围来判断;再有就是除法的除数不能为零。 所以最终解法描述如下: 定义误差范围,定义要对比的值,定义运算符数组; 定义判断是否相等的判断方法,传入值和要对比的值的绝对值小于误差范围,即视作相等; 数据转换,由于传入的数字是Int,所以通过...
Algorithem_Matrix
Algorithem_Matrix题目Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: 12Input: mat = [[0,0,0],[0,1,0],[0,0,0]]Output: [[0,0,0],[0,1,0],[0,0,0]] Example 2: 12Input: mat = [[0,0,0],[0,1,0],[1,1,1]]Output: [[0,0,0],[0,1,0],[1,2,1]] 解法
Algorithem_PermutationInString
Algorithem_PermutationInStringGiven two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1’s permutations is the substring of s2. Example 1: 1234Input: s1 = "ab", s2 = "eidbaooo"Output: trueExplanation: s2 contains one permutation of s1 ("ba"). Example 2: 12Input: s1 = "ab", s2 = "eidboaoo"Output: false 解法首先理解 Permutation的意思,题目需要的是 s2包含 s1中字符串的任意一种排列,就返回 true,否则返...
Algorithem_ReverseLinkedList
Algorithem_ReverseLinkedListGiven the head of a singly linked list, reverse the list, and return the reversed list. Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: 12Input: head = [1,2,3,4,5]Output: [5,4,3,2,1] Example 2: 12Input: head = [1,2]Output: [2,1] Example 3: 12Input: head = []Output: [] Constraints: The number of nodes in the list is the range [0, 5000].-5000 <= Node.val <= 5000 Follow up: A linked list can be reversed e...
Algorithem_MergeTwoSortedLists
Algorithem_MergeTwoSortedListsYou are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: 12Input: list1 = [1,2,4], list2 = [1,3,4]Output: [1,1,2,3,4,4] Example 2: 12Input: list1 = [], list2 = []Output: [] Example 3: 12Input: list1 = [], list2 = [0]Output: [0] 解法需求是合并两个有序的LinkList,所以解法是 判断 list1.val 和 list...
Algorithem_Merge Two Binary Trees
Algorithem_Merge Two Binary TreesYou are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of the new tree. Return the merged tree. Note: The merging process must...