테이블뷰 위에 네비게이션 바 아이템에 알림 뱃지를 달으려 했으나, 잘 안되어서 3시간 정도를 소요해 위치 조정을 했다.
class RightViewController : UIViewController, NSXMLParserDelegate {
@IBOutlet weak var tableView: UITableView! --> 뷰는 뷰로 테이블뷰는 아웃렛으로 스토리보드의 테이블뷰와 연결시킨다.
let myFirstLabel = UILabel()
let myFirstButton = UIButton()
let myFirstImage = UIImage(named: "ic_menu_black_24dp")
let myImage = UIImage(named: "12")
override func viewDidLoad() {
super.viewDidLoad()
myFirstLabel.text = "●"
myFirstLabel.font = UIFont(name: "MarkerFelt-Thin", size: 30)
myFirstLabel.textColor = UIColor.redColor()
myFirstLabel.textAlignment = .Center
myFirstLabel.numberOfLines = 5
myFirstLabel.frame = CGRectMake(9, 0, 32, 32)
myFirstButton.setTitle("4", forState: .Normal)
myFirstButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
myFirstButton.frame = CGRectMake(13, 5, 22, 22)
myFirstButton.addTarget(self, action: "pressed:", forControlEvents: .TouchUpInside)
var imageViewObject :UIImageView
imageViewObject = UIImageView(frame:CGRectMake(7, 13, 25, 25))
imageViewObject.image = UIImage(named:"ic_notifications_black_24dp")
let myFirstImageView = UIImageView(image: myFirstImage)
var image2ViewObject :UIImageView
image2ViewObject = UIImageView(frame:CGRectMake(0, 0, 280, 47))
image2ViewObject.image = UIImage(named:"12")
let myImageView = UIImageView(image: myImage)
self.view.addSubview(imageViewObject)
self.view.sendSubviewToBack(imageViewObject)
self.view.addSubview(image2ViewObject)
self.view.sendSubviewToBack(image2ViewObject)
self.view.addSubview(myFirstLabel)
self.view.addSubview(myFirstButton)
}
아래는 숫자와 원을 없애는 코드이다.
func pressed(sender: UIButton!) {
myFirstButton.setTitle("", forState: .Normal)
myFirstLabel.text = ""
}
}
댓글 달기