let button = UIButton() //警告マークの文字・フォント・色を設定 button.setAttributedTitle(NSAttributedString(string: "\u{f06a}", attributes: [NSFontAttributeName: UIFont(name: "FontAwesome", size: 20)!, NSForegroundColorAttributeName:UIColor(hexString: "#d83c2a", alpha: 1)] ), forState: UIControlState.Normal) //背景のサイズと角丸の設定 let radius = 12 button.frame = CGRectMake(0, 0, CGFloat(radius*2), CGFloat(radius*2)) button.layer.cornerRadius = CGFloat(radius) //背景色 button.backgroundColor = UIColor(red: 1, green: 1, blue: 1,alpha: 1) //配置場所を右端に設定 button.layer.position = CGPoint(x: UIScreen.mainScreen().bounds.width-20, y:CGFloat(radius)) //ボーダーを除去 button.layer.borderWidth = 0 //viewにボタンを追加する self.sampleView.addSubview(button)