Using Animoji/Memoji as Profile Photo

How to add image in UITableViewRowAction?

Finally in iOS 11, SWIFT 4 We can add add image in UITableView's swipe action with help of UISwipeActionsConfiguration

@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

let action = UIContextualAction(style: .normal, title: "Files", handler: { (action,view,completionHandler ) in
//do stuff
completionHandler(true)
})
action.image = UIImage(named: "apple.png")
action.backgroundColor = .red
let configuration = UISwipeActionsConfiguration(actions: [action])

return configuration
}

Sample Image

WWDC video at 28.34

Apple Doc

Note: I have used 50*50 points apple.png image with 50 tableview row height

How do you set the avatar of API-triggered messages?

When sending messages through a web-request - you can supply the icon_emoji property with a supported emoji name, such as:

{
..
"icon_emoji":":ghost"
}

Or, with an icon_url property:

{
..
"icon_url":"<your valid url>"
}

Create a User with Profile Picture with Parse in Swift

Please check below code , add a photo fields into your user table with parse.com

 var user = PFUser()

let imageData = UIImageJPEGRepresentation(userDetails.getPhoto(), 0.05)
let imageFile = PFFile(name:"image.jpg", data:imageData)
imageFile.save()

user.username = usrEntered
user.password = pwdEntered
user.email = emlEntered

user.setObject(imageFile, forKey: "photo")

user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
// Hooray! Let them use the app now.
self.messageLabel.text = "User Signed Up";
} else {
// Show the errorString somewhere and let the user try again.
}
}


Related Topics



Leave a reply



Submit