Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用圆形图像配置文件设置UIBarButtonItem_Ios_Swift_Uinavigationcontroller_Uitabbarcontroller_Uibarbuttonitem - Fatal编程技术网

Ios 使用圆形图像配置文件设置UIBarButtonItem

Ios 使用圆形图像配置文件设置UIBarButtonItem,ios,swift,uinavigationcontroller,uitabbarcontroller,uibarbuttonitem,Ios,Swift,Uinavigationcontroller,Uitabbarcontroller,Uibarbuttonitem,如何使用圆形图像配置文件设置UIBarButton 您是否尝试过在imageView中设置内容模式 imageView.contentMode = .scaleAspectFill 未能设置约束,这就是其行为的原因 imageView.widthAnchor.constraint(equalToConstant: buttonWidth).isActive = true imageView.heightAnchor.constraint(equalToConstant: bu

如何使用圆形图像配置文件设置UIBarButton


您是否尝试过在imageView中设置内容模式

imageView.contentMode = .scaleAspectFill

未能设置约束,这就是其行为的原因

    imageView.widthAnchor.constraint(equalToConstant: buttonWidth).isActive = true
    imageView.heightAnchor.constraint(equalToConstant: buttonHeight).isActive = true

已修复问题。

您可以将imageView放置在UIView中。它应该解决宽度问题。你可以参考这个答案:它代表右钮扣,而不是40高的标题。。。你的角半径应该是20你要找的宽度是多少?我把验尸官的半径设为20
    imageView.widthAnchor.constraint(equalToConstant: buttonWidth).isActive = true
    imageView.heightAnchor.constraint(equalToConstant: buttonHeight).isActive = true