9
UIBarButtonItem พร้อมรูปภาพที่กำหนดเองและไม่มีเส้นขอบ
ฉันต้องการสร้าง UIBarButtonItem ด้วยรูปภาพที่กำหนดเอง แต่ฉันไม่ต้องการให้เส้นขอบที่ iPhone เพิ่มเข้ามาเนื่องจากรูปภาพของฉันมีเส้นขอบพิเศษ เหมือนกับปุ่มย้อนกลับ แต่เป็นปุ่มเดินหน้า แอพนี้มีไว้สำหรับโครงการ inHouse ดังนั้นฉันไม่สนใจว่า Apple จะปฏิเสธหรืออนุมัติหรือชอบ :-) ถ้าฉันใช้คุณสมบัติ initWithCustomView: v ของ UIBarButtonItem ฉันสามารถทำได้: UIImage *image = [UIImage imageNamed:@"right.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage: [image stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateNormal]; [button setBackgroundImage: [[UIImage imageNamed: @"right_clicked.png"] stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateHighlighted]; button.frame= CGRectMake(0.0, 0.0, image.size.width, image.size.height); [button …