Ios UIViewContentMode与uicontrol内容水平对齐
我有一个UIButton,我想将它的imageView向左对齐。 当我尝试时: self.cancelButton.imageView.contentMode=UIViewContentModeLeft 它似乎不起作用,因为imageView仍将位于中心UIViewContentModeCenter 但是当我使用 self.cancelButton.contentHorizontalAlignment=uicontrol内容HorizontalAlignment左侧Ios UIViewContentMode与uicontrol内容水平对齐,ios,objective-c,uiimageview,uibutton,uicontrol,Ios,Objective C,Uiimageview,Uibutton,Uicontrol,我有一个UIButton,我想将它的imageView向左对齐。 当我尝试时: self.cancelButton.imageView.contentMode=UIViewContentModeLeft 它似乎不起作用,因为imageView仍将位于中心UIViewContentModeCenter 但是当我使用 self.cancelButton.contentHorizontalAlignment=uicontrol内容HorizontalAlignment左侧 它与imageView完美对
它与imageView完美对齐。有人能向我解释为什么UIViewContentModeLeft这样的行为也应该起作用吗?任何UIControl元素都将使用contentHorizontalAlignment和contentVerticalAlignment属性来覆盖其子UIView和UIImageView的contentMode。默认contentHorizontalAlignment将覆盖您的contentMode,直到您将按钮的contentHorizontalAlignment显式设置为所需