2

I'm trying to set the layer properties of multiple buttons connected to an IBOutletCollection but the IBOutletCollection doesn't let me access UIButton.layer the same as it does for a regular IBOutlet.

Interface file:

@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *customButton;
@property (weak, nonatomic) IBOutlet UIButton *myButton;

Implementation file

myButton.layer.cornerRadius = 9; // this works for individual buttons
customButton.layer.cornerRadius = 9; //This doesn't work for the collection of buttons

Am I missing something? Do I need to do something else to adjust the layer properties of a collection? I've imported QuartzCore into my implementation file.

I'm only trying to add 4 buttons to the collection so its not the end of the world if I have to set each on independently but it would be nice to be able to set them up together.

Old Name
  • 273
  • 1
  • 3
  • 13
  • Note that customButton is NSArray type. NSArray has not layer property. May be you should change this property in loop? – stosha Jun 16 '13 at 04:27

1 Answers1

5

customButton is an NSArray.It doesnt have the layer as property.

Use this

for (UIButton *button in customButton) {
        button.layer.cornerRadius = 9;
    }
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101