2015-09-14 56 views

回答

1

WKInterfaceButton class沒有titleLabel屬性,這就是你得到這個錯誤的原因。要設置標題的對齊方式,請使用其屬性attributedTitle

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; 
paragraphStyle.alignment = NSTextAlignmentCenter; 

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:yourTitle attributes:@{NSParagraphStyleAttributeName: paragraphStyle}]; 
[myWKButton setAttributedTitle:attributedString];