I am fairly new to the objective C scene. I was writing an app, and I noticed I kept repeating myself, so why not create a method instead? I was trying to create a method with multiple parameters, these parameters are the color and location of a UIButton. So essentially everytime i call this method I will be able to create a UIbutton. How would I go about creating this as its own method?
//Left Button
uploadPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[uploadPhotoButton setImage:[UIImage imageNamed:@"uploadphotoicon"] forState:UIControlStateNormal];
uploadPhotoButton.frame = CGRectMake(0, 0, 80, 80);
uploadPhotoButton.clipsToBounds = YES;
uploadPhotoButton.layer.cornerRadius = 80/2.0f;
uploadPhotoButton.layer.borderColor = [UIColor colorWithRed:.102 green:.737 blue:.612 alpha:1.0].CGColor;
uploadPhotoButton.layer.borderWidth = 2.0f;
[self.view addSubview:uploadPhotoButton];
[uploadPhotoButton setCenter:CGPointMake(78, 139)];
[uploadPhotoButton addTarget:self action:@selector(uploadPhotoButton:) forControlEvents:UIControlEventTouchUpInside];
//Right Button
uploadPhotoButton2 = [UIButton buttonWithType:UIButtonTypeCustom];
[uploadPhotoButton2 setImage:[UIImage imageNamed:@"uploadphotoicon"] forState:UIControlStateNormal];
uploadPhotoButton2.frame = CGRectMake(0, 0, 80, 80);
uploadPhotoButton2.clipsToBounds = YES;
uploadPhotoButton2.layer.cornerRadius = 80/2.0f;
uploadPhotoButton2.layer.borderColor = [UIColor colorWithRed:.749 green:.580 blue:.894 alpha:1.0].CGColor;
uploadPhotoButton2.layer.borderWidth = 2.0f;
[self.view addSubview:uploadPhotoButton2];
[uploadPhotoButton2 setCenter:CGPointMake(242, 139)];
[uploadPhotoButton2 addTarget:self action:@selector(uploadPhotoButton:) forControlEvents:UIControlEventTouchUpInside];
As you can see, I am creating two different buttons, just with a different color and location, so i would rather have a method that allows me to create the buttons instead. Please guide me step by step as to how to create this method. Thank you!