小编eve*_*erk的帖子

iOS - 影子在UILabel传播

我想在我的UILabel中增加阴影的传播,但我找不到属性来做到这一点.我在下面添加了一张照片来说明问题.

所需标签阴影的示例,以及当前标签阴影.

顶部标签是我能够在Photoshop中创建的所需效果.底部标签说明了我能够在iOS中找到的属性.这是我用于底部标签的代码.

let bottomLabel = UILabel(frame: CGRectMake(0, 0, maxWidth, 18))
bottomLabel.backgroundColor = UIColor.clearColor()
bottomLabel.textColor = UIColor.whiteColor()
bottomLabel.font = UIFont.boldSystemFontOfSize(16)
bottomLabel.text = title
bottomLabel.textAlignment = .Center
bottomLabel.numberOfLines = 1
bottomLabel.layer.shadowOffset = CGSize(width: 0, height: 0)
bottomLabel.layer.shadowOpacity = 1
bottomLabel.layer.shadowRadius = 2
Run Code Online (Sandbox Code Playgroud)

我确实找到了使用第二个标签作为阴影的建议,但这没有给出所需的结果.这是该标签的代码.

let bottomLabelShadow = UILabel(frame: CGRectMake(0, 1, maxWidth, 18)) 
bottomLabelShadow.backgroundColor = UIColor.clearColor()
bottomLabelShadow.textColor = UIColor.blackColor()
bottomLabelShadow.font = UIFont.boldSystemFontOfSize(16)
bottomLabelShadow.text = title
bottomLabelShadow.textAlignment = .Center
bottomLabelShadow.numberOfLines = 1
bottomLabelShadow.layer.shadowOffset = CGSize(width: 0, height: 0)
bottomLabelShadow.layer.shadowOpacity = 1
bottomLabelShadow.layer.shadowRadius = 2
Run Code Online (Sandbox Code Playgroud)

shadow uilabel ios swift

12
推荐指数
2
解决办法
1万
查看次数

Safari - Webkit 联系人自动填充按钮图标更改空白颜色

我的网站上有一个深色表单,我想在输入字段为空时更改联系人自动填充按钮的颜色。如何才能实现这一目标?

表格示例

css safari webkit autofill

7
推荐指数
1
解决办法
3648
查看次数

iOS 11-导航栏大标题自定义偏移

是否可以更改大导航栏标题的x偏移?我想将x偏移更改为36pt。

导航栏

uinavigationbar uinavigationcontroller uinavigationitem swift ios11

6
推荐指数
2
解决办法
1728
查看次数

在 Swift 中获取 UIImage 的主颜色

我正在尝试在 Swift 中获取 UIImage 的主要颜色,并尝试移植此代码。不幸的是,代码不断返回相同的颜色。我看到这里提供的答案也不断返回相同的颜色。我避免使用 CIFilter,因为它只返回我研究中的平均颜色。

下面是移植的代码。我已将 CGContext Data 设置为 nil,因为 Swift 可以在其打开时处理内存,并且在我的测试中它给出了很多内存错误。

func mainColors(image:UIImage, detail: Int) -> [UIColor] {
            //COLOR PROCESS STEP 1:
            //Determine the detail.
                var dimension = 10
                var flexibility = 2
                var range = 60

        //Low detail.
            if detail == 0 {
                dimension = 4
                flexibility = 1
                range = 100
            }
        //High detail.
            else if detail == 2 {
                dimension = 100
                flexibility = 10
                range = 20
            }

        //COLOR PROCESS …
Run Code Online (Sandbox Code Playgroud)

uiimage cgcontext uicolor ios swift

5
推荐指数
1
解决办法
8614
查看次数

CollectionViewLayout补充视图高度等于内容

我有一个UICollectionViewLayout子类,其中包含一个包含多行UILabel的补充视图.问题是并非所有文本在某一点都可见,我如何给予补充视图高度等于其内容?

布局示例.

ios uicollectionview uicollectionviewlayout uicollectionreusableview swift

5
推荐指数
1
解决办法
1591
查看次数

UIView反转蒙版MaskView

我想对我的UIView应用倒置蒙版。我将蒙版设置为带有透明图像的UIImageView。但是输出

view.mask = imageView
Run Code Online (Sandbox Code Playgroud)

不是理想的结果。如下图所示,如何获得所需的结果?期望的结果使用蒙版切口作为透明度。当我检查视图的蒙版时,它不是CAShapeLayer,所以我不能那样翻转它。

发生的情况与我想要的情况的说明。

mask uiview swift

5
推荐指数
1
解决办法
1652
查看次数