내 컬렉션 뷰 셀의 사진 썸네일을 얻고 싶습니다. 이것이 내가 한 방법입니다.
imageManager.requestImageForAsset(asset as! PHAsset, targetSize:CGSizeMake(80, 80), contentMode: .AspectFit, options: nil, resultHandler: {(result, info)->Void in
cell.setThumbnail(result!)
}
})
이것은 늘어난 썸네일을 얻게 될 것입니다. 저는 iPhone의 사진 앱처럼 사진의 원래 비율을 유지하는 정사각형의 잘린 썸네일을 원합니다.
어떤 아이디어? 저는 iOS 프로그래밍이 처음 이니 신속하게 응답 해주세요. 저는 신속하게 시작합니다. 감사합니다.
에서 속성을 설정할 수있는 Interface Builder로 작업하는 경우 UIImageView
다음 두 속성을 살펴보세요.
보기 모드는 늘어난 것처럼 보이거나 맞는지 여부에 영향을줍니다. 때로는 기술적으로 적합하더라도 이미지가 너무 크면 셀 직사각형의 경계를 넘을 수 있습니다. 이 경우 "Clip Subviews"를 활성화하여 이미지가 이미지 뷰 사각형의 경계를 벗어나 표시되지 않도록 할 수 있습니다.
Interface Builder를 사용하지 않는 경우 다음과 같이 코드의 셀에 이러한 속성을 모두 설정할 수 있습니다.
// This is assuming your UIImageView inside your cell is
// called 'thumbnail'. You could put this code inside of your
// .setThumbnail() function instead--though it's not clear
// what all that is doing from you code snippet.
cell.thumbnail.clipsToBounds = true
cell.thumbnail.contentMode = .ScaleAspectFill
선택할 수있는 다양한 콘텐츠 모드는 UIKit에서 다음과 같이 정의됩니다.
public enum UIViewContentMode : Int {
case ScaleToFill
case ScaleAspectFit // contents scaled to fit with fixed aspect. remainder is transparent
case ScaleAspectFill // contents scaled to fill with fixed aspect. some portion of content may be clipped.
case Redraw // redraw on bounds change (calls -setNeedsDisplay)
case Center // contents remain same size. positioned adjusted.
case Top
case Bottom
case Left
case Right
case TopLeft
case TopRight
case BottomLeft
case BottomRight
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다