I've been trying to get a sync button to display Last Sync at (time&date). But All I get is one line with shortened text.
// Sync Button syncBtn.frame = CGRectMake(15, height-60, 120, 40) syncBtn.addTarget(self, action: "syncBtnPressed", forControlEvents: UIControlEvents.TouchUpInside) syncBtn.setTitle("Last Sync: Never", forState: UIControlState.Normal) syncBtn.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal) syncBtn.layer.borderColor = UIColor.whiteColor().CGColor syncBtn.layer.borderWidth = 1 syncBtn.layer.cornerRadius = 5 syncBtn.titleLabel?.font = UIFont(name: "Avenir", size: 10) syncBtn.alpha = 0.5 syncBtn.titleLabel?.sizeToFit() syncBtn.titleLabel?.textAlignment = NSTextAlignment.Center syncBtn.titleLabel?.numberOfLines = 2 self.view.addSubview(syncBtn) This is the function to get and set the date on the label
func printTimestamp(){ var timestamp = NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: .ShortStyle, timeStyle: .ShortStyle) self.syncBtn.titleLabel?.text = ("Last Sync at: " + timestamp) } Anyone able to solve this problem?