Objective c 将框架分为不同类别的位置和大小
我有一个UIView类,要创建结构,我需要:Objective c 将框架分为不同类别的位置和大小,objective-c,xcode,Objective C,Xcode,我有一个UIView类,要创建结构,我需要: - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code //creo la view CGRectMake(0, 0, 100, 100); //I would just like the frame size self.clipsToBounds = YES;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
//creo la view
CGRectMake(0, 0, 100, 100); //I would just like the frame size
self.clipsToBounds = YES;
}
return self;
}
所以我确定了框架的位置和大小。
我在主UIViewController中调用这个类
有没有办法只在类中创建帧的大小,并在UIViewController中设置位置
MyClass *myClass1 = [[Item alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; //I would just like the frame position
[self.view addSubview:myClass1];
非常感谢 我想您看到的是类似initWithOrigin: 现在你可以把它当作
MyClass *myClass1 = [[MyClass alloc] initWithOrigin:CGPointMake(0,0)];
[self.view addSubview:myClass1];
MyClass *myClass1 = [[MyClass alloc] initWithOrigin:CGPointMake(0,0)];
[self.view addSubview:myClass1];