swift3 自定义UITableViewCell中的图片靠右布局问题

hexx 2016-11-25 04:22:37
在swift3.0.1中自定义UITableViewCell,内有UIImageView靠右布局,语句如下:
class myTableViewCell: UITableViewCell {
var myImageView: UIImageView?
...
self.myImageView = UIImageView(frame:CGRect(x: self.contentView.bounds.size.width - 41, y: 23, width: 30, height: 30))
self.contentView.addSubview(self.myImageView!)
...
}

self.tableView = UITableView(frame:CGRect(x:0, y:20, width:self.view.bounds.width,
height:self.view.bounds.height - 90), style:.plain)

用模拟机测试,在iphone5、iphone5s图片显示靠最右,但在iphone6及以上、ipad图片显示并非靠最右,怎样解决?
...全文
655 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hexx 2016-11-28
  • 打赏
  • 举报
回复
最后还是用约束解决了
网络咖啡 2016-11-26
  • 打赏
  • 举报
回复
可以使用AutoLayout进行布局,可以很方便的实现界面管理的,不用写代码的

1,420

社区成员

发帖
与我相关
我的任务
社区描述
Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Objective-C共同运行于MAC OS和iOS平台,用于搭建基于苹果平台的应用程序。
swift 技术论坛(原bbs)
社区管理员
  • Swift
  • 网罗开发
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧