gpt4 book ai didi

ios - 聊天应用程序中彩色背景的奇怪形状

转载 作者:行者123 更新时间:2023-11-28 07:40:52 25 4
gpt4 key购买 nike

我正在尝试制作一些小型聊天应用,消息周围有灰色背景:

enter image description here

问题是灰色背景是一个奇怪的形状(就像我用红色画的那样)而不是一个简单的圆角矩形:

messageLbl.frame = CGRect(x: 0, y: 0, width: self.resultsScrollView.frame.size.width-94, height: CGFloat.greatestFiniteMagnitude+32)
messageLbl.backgroundColor = UIColor.groupTableViewBackground
messageLbl.lineBreakMode = NSLineBreakMode.byWordWrapping
messageLbl.textAlignment = NSTextAlignment.left
messageLbl.numberOfLines = 0
messageLbl.font = UIFont(name: "Helvetica Neuse", size: 17)
messageLbl.textColor = UIColor.black
messageLbl.text = self.messageArray[i]
messageLbl.sizeToFit()
messageLbl.layer.zPosition = 20
//messageLbl.frame.origin.x = (self.resultsScrollView.frame.size.width - self.messageX) - messageLbl.frame.size.width //--> value of 449.5 too much right
messageLbl.frame.origin.y = self.messageY
//messageLbl.frame.origin.y = 20
messageLbl.frame.origin.x = 40
self.resultsScrollView.addSubview(messageLbl)
self.messageY += messageLbl.frame.size.height + 30
let frameLbl:UILabel = UILabel()
frameLbl.frame.size = CGSize(width: messageLbl.frame.size.width, height: messageLbl.frame.size.height + 10)
//frameLbl.frame.origin.x = (self.resultsScrollView.frame.size.width - self.frameX) - frameLbl.frame.size.width
frameLbl.frame.origin.x = 20
frameLbl.frame.origin.y = self.frameY
frameLbl.backgroundColor = UIColor.groupTableViewBackground
frameLbl.layer.masksToBounds = true
frameLbl.layer.cornerRadius = 10
self.resultsScrollView.addSubview(frameLbl)
self.frameY += frameLbl.frame.size.height + 20
let img: UIImageView = UIImageView()
img.image = self.myImg
img.frame.size = CGSize(width: 34,height: 34)
//img.frame.origin.x = (self.resultsScrollView.frame.size.width - self.imgX) - img.frame.size.width
frameLbl.frame.origin.x = 70
img.frame.origin.y = self.imgY

img.layer.zPosition = 30
img.layer.cornerRadius = img.frame.size.width/2
img.clipsToBounds = true
self.resultsScrollView.addSubview(img)
self.imgY += frameLbl.frame.height + 20
self.resultsScrollView.contentSize = CGSize(width: theWidth, height: self.messageY)

最佳答案

frameLbl.frame.origin.x = 70

这段代码很奇怪。您可以将 x 移动到 40 并查看结果。

关于ios - 聊天应用程序中彩色背景的奇怪形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52282381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com