我有安裝一個按鈕這樣的:調整大小圖像使用capinsets
// Create facebook login button
facebookLoginButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 20, 300,50)];
facebookLoginButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
//NSLog(@"facebook button view height is %f",facebookLoginButton.bounds.size.height);
//NSLog(@"facebook button view width is %f",facebookLoginButton.bounds.size.width);
UIImage *facebookButton = [[UIImage imageNamed:@"FacebookLogin"]
resizableImageWithCapInsets:UIEdgeInsetsMake(16,140,86,92)];
[facebookLoginButton setBackgroundImage:facebookButton forState:UIControlStateNormal];
我已經在Photoshop中創建的圖像的按鈕,這是200(W)×100(H)像素。首先,這是iphone4/5上使用的視網膜圖像的正確大小,是否適合裝入高度爲50英寸的登錄幀的按鈕?另一個寬度與拉伸無關。
其次,下面是一個示例圖片。我似乎無法解決'resizableImageWithCapInsets:UIEdgeInsetsMake'的正確插入問題。我如何解決這個問題?除了我已經見過的Android連接示例之外,有沒有關於如何做到這一點的教程。
示例圖像是200x100像素,需要拉伸以便F保持在左側和右側部分延伸 – StuartM
好吧,我已經編輯了答案,以便與您實際提供的圖像一起播放。 – matt
謝謝,我接受了答案 - 我實際上在這裏創建了另一個問題http://stackoverflow.com/questions/15713799/image-not-resizing-correctly-using-resizableimagewithcapinsets - 這實際上是相同的答案。但是,如果你能提供關於如何解決這個問題的信息,或者任何有用的教程都可以從中學到很多。我找不到任何有用/深入的Apple文檔。 – StuartM