我正在尝试为我成功的UIImage添加一个六边形面具.但是我无法绕六边形面具的两侧.我想加上cell.profilePic.layer.cornerRadius = 10; 会做的伎俩,但事实并非如此.
这是我的代码:
CGRect rect = cell.profilePic.frame;
CAShapeLayer *hexagonMask = [CAShapeLayer layer];
CAShapeLayer *hexagonBorder = [CAShapeLayer layer];
hexagonBorder.frame = cell.profilePic.layer.bounds;
UIBezierPath *hexagonPath = [UIBezierPath bezierPath];
CGFloat sideWidth = 2 * ( 0.5 * rect.size.width / 2 );
CGFloat lcolumn = ( rect.size.width - sideWidth ) / 2;
CGFloat rcolumn = rect.size.width - lcolumn;
CGFloat height = 0.866025 * rect.size.height;
CGFloat y = (rect.size.height - height) / 2;
CGFloat by = rect.size.height - y;
CGFloat midy = rect.size.height / …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码将图像保存到parse.com:
NSData *imageData = UIImagePNGRepresentation(profileImage);
PFFile *imageFile = [PFFile fileWithName:@"Profileimage.png" data:imageData];
[imageFile saveInBackground];
PFUser *user = [PFUser currentUser];
user[@"fullName"] = name;
user[@"Location"] = location;
user[@"gender"] = gender;
user[@"email"] = email;
user[@"ProfilePic"] = imageFile;
[user saveInBackground];
Run Code Online (Sandbox Code Playgroud)
问题是这似乎没有保存图像文件来解析,因为我的数据浏览器中没有填充任何内容.这里的代码看起来很好,但是你们可以看到它有什么问题吗?
使用以下代码从Facebook下载图像:
NSURL *pictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1", facebookID]];
NSData *data = [[NSData alloc] initWithContentsOfURL:pictureURL];
UIImage *profileImage = [[UIImage alloc] initWithData:data];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢
我正在尝试实现一个表视图,其中所有行都有2个按钮,然后在它们所在的索引行处执行某些操作.
这是我到目前为止:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"NotificationCell";
NotificationCell *cell = (NotificationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[NotificationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NotificationObject *notification = nil;
notification = [_notificationArray objectAtIndex:indexPath.row];
cell.profileImage.image = notification.profileImage;
cell.profileImage.layer.cornerRadius = cell.profileImage.frame.size.height /2;
cell.profileImage.layer.masksToBounds = YES;
cell.profileImage.layer.borderWidth = 0;
cell.detailTextView.text = notification.action;
UIButton *denyButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIButton *acceptButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//set the position of the button
denyButton.frame = CGRectMake(cell.frame.origin.x + 285, cell.frame.origin.y + …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用字符串作为键创建一个映射,将值作为一组Runner对象创建.
然而,当我用一些随机数据填充地图时,我得到一个NullPointerException并且我无法弄明白.
请参阅以下代码:
public class EventRunners
{
// instance variables - replace the example below with your own
public Map<String, Set<Runner>> runnerMap;
/**
* Constructor for objects of class EventRunners
*/
public EventRunners()
{
Map <String, Set<Runner>> runnerMap = new HashMap<>();
}
/**
* Populates the map with appropriate data
*/
public void createMap()
{
/**
* Create the Runner objects
*/
Runner runner1 = new Runner("Simon", "Strain", "4:45:00" );
Runner runner2 = new Runner("James", "Cashin", "4:45:00" );
Runner runner3 …Run Code Online (Sandbox Code Playgroud)