相关疑难解决方法(0)

在Swift中用纯色创建UIImage

我想以编程方式创建一个由纯色填充的UIImage.任何人都知道如何在Swift中执行此操作?

uiimage ios swift

122
推荐指数
9
解决办法
8万
查看次数

Segment Control 的 SelectedTintColor 在 iOS 13 上不是圆角

圆角在 iOS 12 及更低版本上运行良好,但在 iOS 13 上已损坏。我创建了一个自定义 Segment 控件类。

代码:

class SegmentedControl: UISegmentedControl {
    override func layoutSubviews() {
      super.layoutSubviews()
      layer.cornerRadius = self.bounds.size.height / 2.0
      layer.borderColor = UIColor(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0).cgColor
      layer.borderWidth = 1.0
      layer.masksToBounds = true
      clipsToBounds = true

   }
}
Run Code Online (Sandbox Code Playgroud)

我已经阅读了这篇文章 -如何在 iOS 13 的 UISegmentedControl 中更改段的颜色? 但我找不到任何解决方案。

截屏: 在此处输入图片说明

uisegmentedcontrol ios swift4 ios13

7
推荐指数
2
解决办法
4854
查看次数

iOS13后分段控制器背景灰色

我目前在使用 iOS 13 分段控制器时遇到问题。我有这个方法来改变我的分段控制器的外观,它在 iOS 13 出来之前一直很好用。现在我的 segmentedController 始终具有灰色背景,即使我将背景颜色设置为白色、黑色或其他颜色。

我能做什么?

- (void)modifySegmentedControl{
    if (@available(iOS 13.0, *)) {
        [_segmentedControl setBackgroundColor:UIColor.clearColor];
        [_segmentedControl setSelectedSegmentTintColor:UIColor.clearColor];
    } else {
         //I had this for <iOS13, it works great
        [_segmentedControl setBackgroundColor:UIColor.clearColor];
        [_segmentedControl setTintColor:UIColor.clearColor];
    }

    [_segmentedControl setTitleTextAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor colorWithRed:0.25 green:0.25 blue:0.25 alpha:0.6], NSForegroundColorAttributeName,
        [UIFont fontWithName:@"Poppins-Medium" size:15.0], NSFontAttributeName,
       nil]
    forState: UIControlStateNormal];

    [_segmentedControl setTitleTextAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor colorWithRed:0.25 green:0.25 blue:0.25 alpha:1.0], NSForegroundColorAttributeName,
        [UIFont fontWithName:@"Poppins-Medium" size:15.0], NSFontAttributeName,
       nil]
    forState: UIControlStateSelected];

    self->greenBar = [[UIView alloc] init];
//This needs to be …
Run Code Online (Sandbox Code Playgroud)

objective-c uisegmentedcontrol ios

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

标签 统计

ios ×3

uisegmentedcontrol ×2

ios13 ×1

objective-c ×1

swift ×1

swift4 ×1

uiimage ×1