//准備工作 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50,50,100,40); button.backgroundColor = [UIColor blueColor]; //關鍵語句 button.layer.cornerRadius = 2.0;//2.0是圓角的弧度,根據需求自己更改 button.layer.borderColor = [UIColor blackColor];//設置邊框顏色 button.layer.borderWidth = 1.0f;//設置邊框顏色
