avatarImage = [UIButton buttonWithType:UIButtonTypeCustom];
//给按钮加一个白色的板框
avatarImage.layer.borderColor = [[UIColor whiteColor] CGColor];
avatarImage.layer.borderWidth = 1.0f;
//给按钮设置弧度,这里将按钮变成了圆形
avatarImage.layer.cornerRadius = 25.0f;
avatarImage.backgroundColor = [UIColor redColor];
avatarImage.layer.masksToBounds = YES;
原文地址:http://blog.csdn.net/u010742414/article/details/45968713