Привет, у меня есть класс RqButton
, полученный из UIButton
, который я использую для персонализации своих кнопок.Передайте еще один аргумент с initWithFrame: CGRectMake()
If If do button = [[RqButton alloc] initWithFrame:CGRectMake(xz, yz, sq, sq)];
все работает как ожидалось, но я хочу передать другой параметр RqButton
, и я не знаю как.
Это мой RqButton.m
#import "RqButton.h"
@implementation RqButton
+ (RqButton *)buttonWithType:(UIButtonType)type
{return [super buttonWithType:UIButtonTypeCustom];}
- (void)drawRect:(CGRect)rect r:(int)r
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
float width = CGRectGetWidth(rect);
float height = CGRectGetHeight(rect);
UIColor *borderColor = [UIColor colorWithRed:0.99f green:0.95f blue:0.99f alpha:1.00f];
CGFloat BGLocations[2] = { 0.0, 1.0 };
CGFloat BgComponents[8] = { 0.99, 0.99, 0.0 , 1.0,
0.00, 0.00, 0.00, 1.0 };
CGColorSpaceRef BgRGBColorspace = CGColorSpaceCreateDeviceRGB();
CGGradientRef bgRadialGradient = CGGradientCreateWithColorComponents(BgRGBColorspace, BgComponents, BGLocations, 2);
UIBezierPath *roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(0, 0, width, height) cornerRadius: 5];
[roundedRectanglePath addClip];
CGPoint startBg = CGPointMake (width*0.5, height*0.5);
CGFloat endRadius= r;
CGContextDrawRadialGradient(ctx, bgRadialGradient, startBg, 0, startBg, endRadius, kCGGradientDrawsAfterEndLocation);
CGColorSpaceRelease(BgRGBColorspace);
CGGradientRelease(bgRadialGradient);
[borderColor setStroke];
roundedRectanglePath.lineWidth = 2;
[roundedRectanglePath stroke];
}
@end
Вы видите, что я хочу, чтобы иметь возможность вызвать класс при прохождении CGrect
и INT R для того, чтобы использовать его в строке CGFloat endRadius = г;
Конечно, button = [[RqButton alloc] initWithFrame:CGRectMake(xz, yz, sq, sq) :1];
не будет работать так, но теперь, каков способ сделать это?
Спасибо за вашу помощь, Алекс
Приветствия матового, идеальное решение! – user2875404