self.manBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.manBtn.frame = CGRectMake(aliasName.frame.origin.x, CGRectGetMaxY(lineview2.frame) + 2, lineview2.frame.size.width/3, aliasName.frame.size.height);
[self.manBtn setTitle:@"男" forState:UIControlStateNormal];
[self.manBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:UserSex] isEqualToString:@"M"]) {
[self.manBtn setImage:[UIImage imageNamed:@"圈选_2"] forState:UIControlStateNormal];
}else {
[self.manBtn setImage:[UIImage imageNamed:@"圈选_1"] forState:UIControlStateNormal];
}
[self.manBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
[self.manBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, self.manBtn.imageView.bounds.size.width, 0, self.manBtn.imageView.bounds.size.width - 10)];
[self.manBtn addTarget:self action:@selector(manBtnAction) forControlEvents:UIControlEventTouchUpInside];
[self.baseScrollView addSubview:self.manBtn];
具体的间距可以调整以适合自己的界面
网友评论