简体   繁体   中英

Trying to add two images in a UI image

Im new to xcode and was trying to add different images in a table row in a storyboard layout.

let image:UIImage = UIImage(named:
”ster.jpg")!

when i use this code, it makes every table the same image

 let image:UIImage = UIImage(named:
    ”ster.jpg", "blue.jpg")!

My goal is for the 2nd row of the table to have a different image, so when using this code it just creates an error saying " Extra argument in call"

I would start by saying that the way you initialize the UIImage object is wrong. It supports only one image at a time. Thus, you get the error of an extra argument in the call.

To add two images in a row, you better use a horizontal stack view and modify some of its properties (fill equally, spacing, etc).

The way I would do the thing: Drag and drop from library 2 UIImage objects. Embed them in a horizontal stack view. In property inspector set the fill property to equal. Make sure to add constraints.

In case you are using UITableView and want to modify the cell, you will have to create a subclass of UITableViewCell and give it an identifier to use when the TableViewDataSourceDelegate object is fetching the cell data based on the identifier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM