Вопрос по ios – Почему пользовательский образ UIButton не изменяется в Интерфейсном Разработчике?

38

Почему пользовательское изображение UIButton не изменяется с помощью кнопки?

Я установил режим просмотра наScale to Fill в Интерфейсном Разработчике, но в отличие от изображения UIImageView, он не учитывает этот параметр.

Я смотрю не в том месте или это невозможно?

Error: User Rate Limit Exceededstackoverflow.com/questions/2658738/… iwasrobbed
Error: User Rate Limit Exceeded an0

Ваш Ответ

9   ответов
0

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded willc2
76

Error: User Rate Limit ExceededdoesError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededstackoverflow.com/questions/1957317/…
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded willc2
48

Error: User Rate Limit Exceeded

[button setImage:image forState:UIControlStateNormal];
button.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;

In Swift:

button.contentVerticalAlignment = .fill
button.contentHorizontalAlignment = .fill
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededcustom
4

Interface Builder

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededIdentity InspectorError: User Rate Limit ExceededDefined Runtime Attributes:

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

0 = Scale to fill 
1 = Aspect Fit 
2 = Aspect Fill
etc..

Error: User Rate Limit ExceededAttributesError: User Rate Limit ExceededControlError: User Rate Limit ExceededAlignmentError: User Rate Limit Exceeded

SWIFT 3

Error: User Rate Limit Exceeded

button.imageView?.contentMode = .scaleAspectFit
button.contentVerticalAlignment = .fill
button.contentHorizontalAlignment = .fill
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
10

Error: User Rate Limit Exceeded

From Design

  1. Open your xib OR Storyboard.
  2. Select button
  3. Inside Attribute Inspector (Right side) > In "Control" section > select last 4th option for both Horizontal and Verical.

Error: User Rate Limit Exceeded

From Code

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
-2

Error: User Rate Limit Exceeded

self.imageButton.imageView?.clipsToBounds = true
self.imageButton.imageView?.contentMode = UIViewContentMode.ScaleAspectFit

Error: User Rate Limit Exceeded

-5

Error: User Rate Limit Exceeded

28

Error: User Rate Limit Exceeded

here set Control Alignment settings for the button

Error: User Rate Limit Exceeded
11

Error: User Rate Limit Exceeded

button.imageView.contentMode = UIViewContentModeScaleAspectFill;

Error: User Rate Limit Exceeded

[button setImage:yourAwesomeImage forState:UIControlStateNormal]; 
//Or any other state
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededself.button1.imageView.contentMode = UIViewContentModeScaleAspectFill;Error: User Rate Limit Exceeded

Похожие вопросы