我有一个大小为 255x35 的图像,我正在尝试更改 FBLoginView 的大小,但结果很糟糕。我只希望 FBLoginView 适合图像大小。
我的代码:
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.frame = CGRectMake(20, 485, 255, 35);
for (id obj in loginView.subviews)
{
if ([obj isKindOfClass:[UIButton class]])
{
UIButton *loginButton = obj;
UIImage *loginImage = [UIImage imageNamed:@"login.png"];
UIImage *loginImageHighlithed = [UIImage imageNamed:@"login_down.png"];
[loginButton setBackgroundImage:loginImage forState:UIControlStateNormal];
[loginButton setBackgroundImage:nil forState:UIControlStateSelected];
[loginButton setBackgroundImage:loginImageHighlithed forState:UIControlStateHighlighted];
[loginButton sizeToFit];
}
if ([obj isKindOfClass:[UILabel class]])
{
UILabel *loginLabel = obj;
loginLabel.text = @"";
loginLabel.textAlignment = NSTextAlignmentCenter;
loginLabel.frame = CGRectMake(0, 0, 0, 0);
}
}
loginView.delegate = self;
[self.view addSubview:loginView];
[loginView sizeToFit];