나는 여기 바보 같은 짓을하고 있다고 확신한다. UIButton 위에 다른 모든 상태의 배경 이미지를 가져 와서 신축성있는 버전으로 변환하고 단추에 다시 적용 할 수 있도록 카테고리를 만듭니다.아이폰 : 버튼에 스트레칭 가능한 이미지를 적용하면 비활성화 됨
- (void)enableBackgroundImageStrechingWithLeftCapWidth:(float)leftCapWidth withTopCapHeight:(float)topCapHeight;
{
UIImage *backgroundimageNormal = [self backgroundImageForState:UIControlStateNormal];
if (backgroundimageNormal != nil)
{
UIImage *stretchImage = [backgroundimageNormal stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:topCapHeight];
[self setBackgroundImage:stretchImage forState:UIControlStateNormal];
}
UIImage *backgroundimageSelected = [self backgroundImageForState:UIControlStateSelected];
if (backgroundimageSelected != nil)
{
UIImage *stretchImage = [backgroundimageSelected stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:topCapHeight];
[self setBackgroundImage:stretchImage forState:UIControlStateSelected];
}
UIImage *backgroundimageHighlighted = [self backgroundImageForState:UIControlStateHighlighted];
if (backgroundimageHighlighted != nil)
{
UIImage *stretchImage = [backgroundimageHighlighted stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:topCapHeight];
[self setBackgroundImage:stretchImage forState:UIControlStateHighlighted];
}
UIImage *backgroundimageDisabled = [self backgroundImageForState:UIControlStateDisabled];
if (backgroundimageDisabled != nil)
{
UIImage *stretchImage = [backgroundimageDisabled stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:topCapHeight];
[self setBackgroundImage:stretchImage forState:UIControlStateDisabled];
}
}
는 버튼을 지금 클릭 할 수 없습니다 제외하고 작동하는 것 같다