uiimageview

How to successfully add an image in Storyboard in Xcode 6 in Swift?

…衆ロ難τιáo~ 提交于 2020-07-03 02:23:08
问题 I'm very new to Xcode (2 days) and so far I'm finding it fairly frustrating. I'm just trying to add an image to my app's ViewController via he Storyboard, but it does not appear on the simulator. Could someone assist me? 回答1: if you are trying an example project of XCode, you may find a "Images.xcassets" folder in project. Drag your image into this folder. then go to storyboard, focus on your "Image View". in the attributes list, "Image" field, you can choose the image in it's drop-down menu.

Load PDF into UIImage or UIImageView?

一曲冷凌霜 提交于 2020-06-12 03:33:36
问题 This is my first ever question on stackoverflow. I'm trying to load a PDF file stored in Resources into a UIImage/UIImageView object in the iPhone SDK. Is this at all possible without converting the PDF to an image? If not, what are the member functions for converting a PDF into a PNG? I would really prefer to preserve the PDF if at all pssoible. Thanks so much for the help! 回答1: PDFs can be loaded by UIWebView. If you need more control you can use Quartz 2D to render PDFs: Quartz2D 回答2: Now

How can I get autolayout to override a UIImageView's intrinsic size?

纵然是瞬间 提交于 2020-06-10 02:21:28
问题 I'm running into a problem with the autolayout for my detail view in a UISplitViewController . My view hierarchy contains a UIImageView with a decorative element, and the image view's intrinsic size seems to be screwing up the layout of the rest of the controls. These are the constraints I have specified for the image view: H:[UIImageView:0xc83ba90]-(NSSpace(20))-| H:|-(NSSpace(20))-[UIImageView:0xc83ba90] UIImageView:0xc83ba90.bottom == UITextField:0xc83d2d0.bottom V:[UIImageView:0xc83ba90

Snapshotting a `UIView` crashes the app with `NSInvalidArgumentException` “[_UIReplicantView _isSymbolImage]: unrecognized selector sent to instance”

倾然丶 夕夏残阳落幕 提交于 2020-06-01 05:09:41
问题 Hi guys i have just updated XCode to version 11.4 from the app store and when i try to snapshot a UIView on iOS 13.4 like this: extension UIView { func snapshot(at scale: CGFloat) -> UIImage? { let renderer = UIGraphicsImageRenderer(size: bounds.size) let image = renderer.image { [weak self] context in self?.drawHierarchy(in: self?.bounds ?? .zero, afterScreenUpdates: true) } return image } } or like that: extension UIView { func snapshotOld(at scale: CGFloat) -> UIImage? {

Snapshotting a `UIView` crashes the app with `NSInvalidArgumentException` “[_UIReplicantView _isSymbolImage]: unrecognized selector sent to instance”

强颜欢笑 提交于 2020-06-01 05:09:08
问题 Hi guys i have just updated XCode to version 11.4 from the app store and when i try to snapshot a UIView on iOS 13.4 like this: extension UIView { func snapshot(at scale: CGFloat) -> UIImage? { let renderer = UIGraphicsImageRenderer(size: bounds.size) let image = renderer.image { [weak self] context in self?.drawHierarchy(in: self?.bounds ?? .zero, afterScreenUpdates: true) } return image } } or like that: extension UIView { func snapshotOld(at scale: CGFloat) -> UIImage? {

How to add GIF images to Assets folder and load them in UIImageView programmatically

可紊 提交于 2020-05-10 15:41:50
问题 I am trying to put my @2x and @3x GIF images into the Assets folder in Xcode. I have tried the following links but it didn't work for me. Link 1 and Link 2. I am currently loading the GIF files by adding them to my project bundle and accessing it using this let bundleURL = NSBundle.mainBundle() .URLForResource("phone_animation", withExtension: "gif") But I want to load them from my Assets folder. Is there a way I can do it? And how do I load them into my imageview after adding it to Assets?

How to add GIF images to Assets folder and load them in UIImageView programmatically

自作多情 提交于 2020-05-10 15:39:12
问题 I am trying to put my @2x and @3x GIF images into the Assets folder in Xcode. I have tried the following links but it didn't work for me. Link 1 and Link 2. I am currently loading the GIF files by adding them to my project bundle and accessing it using this let bundleURL = NSBundle.mainBundle() .URLForResource("phone_animation", withExtension: "gif") But I want to load them from my Assets folder. Is there a way I can do it? And how do I load them into my imageview after adding it to Assets?

IOS UIImageView & 汤姆猫实例

江枫思渺然 提交于 2020-04-14 16:43:53
【推荐阅读】微服务还能火多久?>>> 一 UIImageView 简介 UIImageView是显示图片的控件,显示图片时, 首先需要把图片加载到UIImage控件中,然后根据UIImage控件,设置到UIImageView相对应的属性中 。 1 创建UIImage对象 //使用应用程序中图片文件创建,IOS4后可以省略图片扩展名; + (UIImage *)imageNamed:(NSString *)name; //根据指定的路径创建UIImage + (UIImage *)imageWithContentsOfFile:(NSString *)path; - (instancetype)initWithContentsOfFile:(NSString *)path; //使用NSData创建 + (UIImage *)imageWithData:(NSData *)data; - (instancetype)initWithData:(NSData *)data; //使用Quartz 2D对象创建UIImage + (UIImage *)imageWithCGImage:(CGImageRef)cgImage; - (instancetype)initWithCGImage:(CGImageRef)cgImage; 注意: UIImage imageNamed

UICollectionViewLayout Not working with UIImage in Swift 5 and Xcode 11

雨燕双飞 提交于 2020-04-07 08:21:11
问题 Please check this attached code and screen short. It's work fine when I set the color of container view but when I add UIImage in cell then it's not working. I changed the imageview content mode but it's not working. class ViewController: UIViewController { @IBOutlet weak var segColumn: UISegmentedControl! @IBOutlet weak var collectionView: UICollectionView! fileprivate var items: [UIImage] = [ // My images ] override func viewDidLoad() { super.viewDidLoad() self.setup() } } extension

Corner radius issue with UIButton

社会主义新天地 提交于 2020-03-21 11:32:12
问题 I want to add a corner radius to a UIButton. It is working fine but a problem occurs when I add image to it. It does not round its corners with images, the image is shown in full rectangle form. Please see the image, I have used the corner radius with red color and the output is as follow: Please help. 回答1: Did you try to use set the masksToBounds: property? Fore example: CALayer *layer = [myView layer]; [layer setMasksToBounds:YES]; [layer setCornerRadius:8.0]; That should do the trick. 回答2: