All posts by stackoverflow

Add border to bottom of .xib (objective-c)

I am trying to only add a border to the bottom of my .xib view. I currently have the following code which places a red border on ALL FOUR sides. I only want the border to be on ONE side, the bottom… How do I set the border to the bottom?

Current Code for class that controls .xib:

- (void)awakeFromNib {

    self.contentView.layer.borderWidth  = 5.0f;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.borderColor  = [UIColor redColor].CGColor;
}

This is what I get:
enter image description here

read more

Add border to bottom of .xib (objective-c)

I am trying to only add a border to the bottom of my .xib view. I currently have the following code which places a red border on ALL FOUR sides. I only want the border to be on ONE side, the bottom… How do I set the border to the bottom?

Current Code for class that controls .xib:

- (void)awakeFromNib {

    self.contentView.layer.borderWidth  = 5.0f;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.borderColor  = [UIColor redColor].CGColor;
}

This is what I get:
enter image description here

read more

better way to calculate euclidean distance with R

I am trying to calculate euclidean distance for Iris dataset. Basically I want to calculate distance between each pair of objects. I have a code working as follows:

for (i in 1:iris_column){
  for (j in 1:iris_row) {

    m[i,j] <- sqrt((iris[i,1]-iris[j,1])^2+
                   (iris[i,2]-iris[j,2])^2+
                   (iris[i,3]-iris[j,3])^2+
                   (iris[i,4]-iris[j,4])^2)
  }
}

Although this works, I don’t think this is a good way to wring R-style code. I know that R has built-in function to calculate Euclidean function. Without using built-in function, I want to know better code (faster and more few lines) which could do the same as my code.

read more