UITextView 在 ios 中添加背景图片
UITextView add background image in ios
我正在尝试添加图像作为 UITextview 的背景
textView.backgroundColor = UIColor(patternImage: UIImage(named: "Background")!)
输出是:-
Textview 不显示单个图像?
您需要在 textView
的 layer
中设置图像,而不是将 backgroundColor
设置为 UIColor(patternImage:)
。所以这样设置图像。
textView.layer.contents = UIImage(named: "Background")!.cgImage
我正在尝试添加图像作为 UITextview 的背景
textView.backgroundColor = UIColor(patternImage: UIImage(named: "Background")!)
输出是:-
Textview 不显示单个图像?
您需要在 textView
的 layer
中设置图像,而不是将 backgroundColor
设置为 UIColor(patternImage:)
。所以这样设置图像。
textView.layer.contents = UIImage(named: "Background")!.cgImage